socket_create
socket_create
socket_create
It creates a endpoint(socket) for communication.
Syntax:
resource socket_create ( int domain, int type, int protocol)
It creates a communication endpoint (a socket), and returns a descriptor to the socket.
The domain parameter sets the domain. Currently, AF_INET and AF_UNIX are understood.
The type parameter selects the socket type. This is one of SOCK_STREAM, SOCK_DGRAM, SOCK_SEQPACKET, SOCK_RAW, SOCK_RDM, or SOCK_PACKET.
It returns a valid socket descriptor on success, or a negative error code on failure. This code may be passed to socket_strerror() to get a textual explanation of the error.
Example:
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
- Defaultly, we use this parameter for creating socket. It returns the resource $socket which is uset to connect to the host.
