socket_create

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.

Leave a Reply


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.