PHP can create a socket service.
First familiar with a few PHP network functions, operating manual address http://php.net/manual/zh/ref.sockets.php
A simple introduction to the socket, which represents the socket, is used for the TCP/IP protocol. A little understanding of network communications know that the establishment of TCP/IP requires two sides of their respective network address ip+ ports port, this ip+port is the socket, communication needs a pair so socket. For example, a common browser request server, the browser side of the ip+ randomly find an idle port number, connect the ip+ service port of the other server (usually the HTTP service is 80).
A code example of the browser requesting the server's socket on the top of the tutorial, deepens understanding:
<?PHP$remote _ip= ' 61.135.169.125 '; $remote _port= ' 80 '; $socket= Localsocket ($remote _ip,$remote _port); EchoThe local socket is$socket\ n "; EchoThe remote socket is$remote _ip:$remote _port\ n "; functionLocalsocket ($dest= ' 61.135.169.125 ',$port=80) { $socket= Socket_create (Af_inet, Sock_dgram,sol_udp); Socket_connect ($socket,$dest,$port);//Dest+port is the remote serverSocket_getsockname ($socket,$addr,$port);//get the local socket, addr + port is localSocket_close ($socket); return $addr.":".$port; }
By outputting The local ip+port it is not difficult to find that the local port is given at random.
PHP Create socket Service