PHP socket 编程中的超时设置
PHP socket 编程中的超时设置.网上找了半天也没找到。贴出来分享之:
设置$socket 发送超时1秒,接收超时3秒:
$socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
socket_set_option($socket,SOL_SOCKET,SO_RCVTIMEO,array("sec"=>1, "usec"=>0 ) );
socket_set_option($socket,SOL_SOCKET,SO_SNDTIMEO,array("sec"=>3, "usec"=>0 ) );