When block on receive, we need to set time-out value to unblock.
Here I set 1 second, but not work. //////set time out if blocking
TIMEVAL tout;
tout.tv_sec = 1; //1 second
tout.tv_usec = 0;
fd_set sRead, sWrite;
sRead.fd_count = sWrite.fd_count = 1;
sRead.fd_array[0] = sWrite.fd_array[0] = s;
iRec = select(0, &sRead, &sWrite, NULL, &tout);
/////// while (1){
//would block here
iRec = recv( newSock, arch, sizeof( arch )-1, 0 );
if (iRec == 0 || iRec == SOCKET_ERROR) break; p->m_strReceive += arch;
}
Asking your Help! Thanks!
Here I set 1 second, but not work. //////set time out if blocking
TIMEVAL tout;
tout.tv_sec = 1; //1 second
tout.tv_usec = 0;
fd_set sRead, sWrite;
sRead.fd_count = sWrite.fd_count = 1;
sRead.fd_array[0] = sWrite.fd_array[0] = s;
iRec = select(0, &sRead, &sWrite, NULL, &tout);
/////// while (1){
//would block here
iRec = recv( newSock, arch, sizeof( arch )-1, 0 );
if (iRec == 0 || iRec == SOCKET_ERROR) break; p->m_strReceive += arch;
}
Asking your Help! Thanks!
解决方案 »
- 设置资源管理器里面的某一个系统应用程序为焦点
- 怎么改变CString中的内容啊?
- 关于CFileDialog对话框中用鼠标右键点击文件时,整个程序就消失了.
- WebBrowser控件NavigatePost数据,为何提交不上去?
- 请问大家在VC++下如何编写图形啊?我在TC下可以编,可是VC++和TC不一样啊!HELP
- 着急!用ExtFloodFill的时候,怎么才能得到被Fill的区域.
- 我想问一下关于视图的问题
- 关于字符串的问题...
- 甩泪求大虾帮帮小弟,关于m_strFilter这个简单问题
- 窗口切换过程中的鼠标双击事件被切换后的窗口响应
- 题 求助:在SMB协议上,当客户机返回一个dialect,要找出这个dialect,程序应该怎么写?
- 菜鸟问,分多给
或者使用异步模式