<?php /* 设置不显示任何错误 */ error_reporting(0); /* 脚本超时为无限 */ set_time_limit(0); /* 开始固定清除 */ ob_implicit_flush(); /* 服务器端的IP和需要开放的端口 */ $address = '192.168.1.2'; $port = 10000; /* 产生一个Socket */ if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) < 0) { echo "socket_create() failed: reason: " . socket_strerror($sock) . "\n"; } /* 把IP地址端口进行绑定 */ if (($ret = socket_bind($sock, $address, $port)) < 0) { echo "socket_bind() failed: reason: " . socket_strerror($ret) . "\n"; } /* 监听Socket连接 */ if (($ret = socket_listen($sock, 5)) < 0) { echo "socket_listen() failed: reason: " . socket_strerror($ret)