Setting time out for connect() function tcp socket programming in C breaks recv()

前端 未结 4 934
孤街浪徒
孤街浪徒 2021-02-06 05:20

In my program If the server is not reachable the connect function take too much time. So i try to give time out to connect using select(). Now the problem is that when i try to

4条回答
  •  没有蜡笔的小新
    2021-02-06 05:39

    The socket should be set to blocking mode again before calling recv().

    fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL, 0) & ~O_NONBLOCK);
    

提交回复
热议问题