Connecting

socket_listen($r [,$i=0]) listens for incoming connections on socket $r, applicable only to types SOCK_STREAM and SOCK_SEQPACKET. $i specifies the maximum number of incoming connections that will be queued for processing. (The maximum is given by SOMAXCONN).

socket_create_listen($i1 [,$i2=128]) returns a socket on port $i1 which only listens to accept new connections. $i2 specifies the maximum number of incoming connections that will be queued for processing.

socket_accept($r) accepts incoming connections to the listening socket $r, and returns a new socket. This function will block until a connection becomes present.

socket_connect($r, $s [,$i=0]) connects to the address $s using the socket $r and port $i.

socket_select(&$arr1, &$arr2, &$arr3, $i1 [,$i2]) waits for arrays of sockets to change status. $arr1 will be watched to see if characters become available for reading. $arr2 will be watched to see if write will not block. $arr3 will be watched for exceptions. $i1 is the seconds and $i2 is the microseconds for the timeout parameter, which is an upper bound on the time elapsed before socket_select() return. If $i1 is NULL, the function can block indefinitely. On exit, this function modifies the arrays to indicate which sockets changed status. It returns the number of sockets contained in the modified arrays.