1. modify php. ini, open extensionphp_sockets.dll2, and the server program SocketServer. php & lt ;? Php ensures that set_time_limit (0) will not time out when connecting to the client; set the IP address and port number $ address127.0.0.1; $ port3046; *** create a SOCKET * AF_INET 1. modify php. ini, open extension = php_sockets.dll
2. server program SocketServer. php
3. client program SocketClient. php
4. test
Run the server program C: \ wamp \ bin \ php \ php5.4.16 \ php.exe C: \ wamp \ www \ SocketServer. php
Run the client program C: \ wamp \ bin \ php \ php5.4.16 \ php.exe C: \ wamp \ www \ SocketClient. php
5. The process is similar to that of C. in fact, it encapsulates the socket of C.
The above section details the code cases for compiling TCP server and client programs in php. For more information, see other related articles in the first PHP community!