Set a timeout on socket_read

前端 未结 4 1895
忘掉有多难
忘掉有多难 2021-01-01 17:08

I was wondering how can I set a timeout on a socket_read call? The first time it calls socket_read, it waits till data is sent, and if no data is s

4条回答
  •  迷失自我
    2021-01-01 17:50

    this set 5 sec timeout of the socket.

    socket_set_option($socket,SOL_SOCKET, SO_RCVTIMEO, array("sec"=>5, "usec"=>0));
    

提交回复
热议问题