Tutorial by Examples

Creating a socket that uses the TCP (Transmission Control Protocol) $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); Make sure the socket is successfully created. The onSocketFailure function comes from Handling socket errors example in this topic. if(!is_resource($socket)) onSocketFailu...
Socket creation Create a socket that uses the TCP. It is the same as creating a client socket. $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); Socket binding Bind connections from a given network (parameter 2) for a specific port (parameter 3) to the socket. The second parameter is us...
socket_last_error can be used to get the error ID of the last error from the sockets extension. socket_strerror can be used to convert the ID to human-readable strings. function onSocketFailure(string $message, $socket = null) { if(is_resource($socket)) { $message .= ": " ....
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 c...

Page 1 of 1