recvfrom设置超时
2014-03-09 01:54
260 查看
struct timeval tv; int ret; tv.tv_sec = 10; tv.tv_usec = 0; if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) { printf("socket option SO_RCVTIMEO not support\n"); return; } if ((ret = recvfrom(s, buf, sizeof buf, 0, NULL, NULL)) < 0) { if (ret == EWOULDBLOCK || ret == EAGAIN) printf("recvfrom timeout\n"); else printf("recvfrom err:%d\n", ret); }
相关文章推荐
- 设置recv的超时
- socket为send和recv设置 4000 超时时间
- socket的send、recv阻塞设置阻塞超时时间
- send,recv在windows与linux下的超时设置
- send和recv非阻塞时如何正确处理WSAEWOULDBLOCK和设置超时
- 设置recv的超时
- ACE_SOCK_Stream send和recv超时设置
- socket为send和recv设置超时时间
- socket 请求接收完整的一个http响应(设置recv 接收超时选项SO_RCVTIMEO)
- socket为send和recv设置超时时间
- C++ Socket为send recv设置堵塞超时时间
- recv、send函数windows和linux下超时设置
- 设置recv的超时
- socket的send、recv阻塞设置阻塞超时时间
- perl中调用recv函数阻塞,设置超时
- recv()与send()设置超时
- linux和windows下用setsockopt设置send(), recv() 超时的参数的一点区别
- socket的send、recv阻塞设置阻塞超时时间
- socket的send、recv阻塞设置阻塞超时时间
- socket 请求接收完整的一个http响应(设置recv 接收超时选项SO_RCVTIMEO)