PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8
socket_set_option - Sets socket options for the socket
Code Examples

socket_set_option( Socket$socket, int$level, int$option, array|string|int$value ): bool

The socket_set_option function sets the option specified by the option parameter, at the specified protocol level, to the value pointed to by the value parameter for the socket.



A Socket instance created with socket_create or socket_accept.


The level parameter specifies the protocol level at which the option resides. For example, to retrieve options at the socket level, a level parameter of SOL_SOCKET would be used. Other levels, such as TCP, can be used by specifying the protocol number of that level. Protocol numbers can be found by using the getprotobyname function.


The available socket options are the same as those for the socket_get_option function.


The option value.

Return Values

Returns true on success or false on failure.


Version Description
8.0.0 socket is a Socket instance now; previously, it was a resource.

Related Functions

Example of socket_set_option

Show all examples for socket_set_option

PHP Version: