PHP Function Socket_Set_Option
The php function socket_set_option allows you to set a number of lower level socket options. The option name is given by the optname parameter, and the option value can be specified by the optval parameter. The option must be a valid option for the protocol level indicated by the level parameter, which is a number that can be obtained by using the getprotobyname() function.
For example you might want to set the linger option. This will ensure that the socket closes even if there is still data to send, if you do not use the linger option then when the socket closes it will just close without sending any of the remaining data.
Another option is SO_REUSEADDR which allows you to reuse the address of a socket that was previously opened. This can help to reduce network traffic by avoiding the need to send out multiple keepalive probes.
You can also set the MCAST_JOIN_GROUP option to add the socket to a multicast group that will monitor packets. This is very useful for logging or monitoring purposes.