PHP UDP server socket
A UDP (user datagram protocol) server, unlike TCP, is not stream-based. It is packet-based, i.e. a client sends data in units called "packets" to the server, and the client identifies clients by their address. There is no builtin function that relates different packets sent from the same client (unlike TCP, where data from the same client are handled by a specific resource created by socket_accept). It can be thought as a new TCP connection is accepted and closed every time a UDP packet arrives.
Creating a UDP server socket
Binding a socket to an address
The parameters are same as that for a TCP server.
Sending a packet
This line sends $data in a UDP packet to $address:$port.
Receiving a packet
The following snippet attempts to manage UDP packets in a client-indexed manner.
Closing the server
socket_close can be used on the UDP server socket resource. This will free the UDP address, allowing other processes to bind to this address