在一个socket使用的过程中,可不可以切换?
解决方案 »
- OPENSSL在Windows中的配置出错
- 外派微软的SDE都做些啥?能学到多少东西?如果不干外派了,好找工作不?
- Visual C++数字图像处理开发入门与编程实践,飞思出的,谁看过这本书
- 高手给指点一下吧,这个问题令我困扰了很久阿,很着急的说。
- 简单的AutoCAD二次开发(只是输出简单图形、文字到CAD)
- 为什么我想获得本窗口图象,得到的却是其它窗口的图象
- 这样的视图如何建呀?
- nPos为什么总是返回0
- 高分奉献,如何解决CEditview在98下的64K的限制问题.
- 两本不错的api介绍的书,推荐给大家
- 链接文件OpenGl32.dll到不存在的输出KERNEL.DLL:IsWow64Process...怎么解决?
- TO mtsh(清风华仔(*****))
unsigned long ul = 1;
while(true)
{
AcceptSocket = accept(ListenSocket, NULL, NULL);
if ( 0 == ul )
{
ul = 1;
}
else
{
ul = 0;
}
//切换模式
iRet = ioctlsocket(ListenSocket, FIONBIO, &ul); closesocket(AcceptSocket);
}
Use with a nonzero argp parameter to enable the nonblocking mode of socket s. The argp parameter is zero if nonblocking is to be disabled. The argp parameter points to an unsigned long value. When a socket is created, it operates in blocking mode by default (nonblocking mode is disabled). This is consistent with BSD sockets.
The WSAAsyncSelect and WSAEventSelect functions automatically set a socket to nonblocking mode. If WSAAsyncSelect or WSAEventSelect has been issued on a socket, then any attempt to use ioctlsocket to set the socket back to blocking mode will fail with WSAEINVAL. To set the socket back to blocking mode, an application must first disable WSAAsyncSelect by calling WSAAsyncSelect with the lEvent parameter equal to zero, or disable WSAEventSelect by calling WSAEventSelect with the lNetworkEvents parameter equal to zero.
对指定的SOCKET进行切换啊。