Canceling a Blocking for Windows Sockets 2
use Winsock2 (WS2_32.DLL) and i want to canceling the 'select()' blocking, in Windows Sockets 1.1 it was possible using the WSACancelBlockingCall(), but it removed for Winsock2 so how can cancel this blocking now?
[223 byte] By [
ishay44] at [2007-11-20 11:44:18]

# 3 Re: Canceling a Blocking for Windows Sockets 2
I checked the MSDN before but I still need to terminate this "separate network activity" thread before closing my application so how i do it?
Do you think I can tell you how you should terminate a thread that you have created without seeing any code??
Additionally you did not say a word that you had created a thread for the network activity in your first post. So please post some code and then we might be able to helo you!
Laitinen
# 4 Re: Canceling a Blocking for Windows Sockets 2
laitinen, first of all I appreciate your willingness to help!
Now here thread for the network activity that i want to terminate whie it 'blocked' in select(), how can i break it from outside the thread?
UINT runProg ( LPVOID pParam )
{
int i;
fd_set readfds;
timeval tv;
int fdsReady = 0;
tv.tv_sec = 0;
tv.tv_usec = 20;
do
{
//printf("Active=%u Total=%u\n",activeThreads, totalThreads);
FD_ZERO(&readfds);
for (/*int*/ i = 0; i < MAX_SERVERS && cfig.tftpConn[i].server; i++)
FD_SET(cfig.tftpConn[i].sock, &readfds);
int fdsReady = select(cfig.maxFD, &readfds, NULL, NULL, &tv);
//if (errno)
// printf("%s\n", strerror(errno));
for (/*int*/ i = 0; fdsReady > 0 && i < MAX_SERVERS && cfig.tftpConn[i].server; i++)
{
if (FD_ISSET(cfig.tftpConn[i].sock, &readfds))
{
//printf("Request Waiting\n");
WaitForSingleObject(sEvent, INFINITE);
currentServer = i;
if (!totalThreads || activeThreads >= totalThreads)
{
_beginthread(
processRequest, // thread function
0, // default security attributes
NULL); // argument to thread function
}
//printf("thread signalled=%u\n",SetEvent(tEvent));
SetEvent(tEvent);
WaitForSingleObject(sEvent, INFINITE);
fdsReady--;
SetEvent(sEvent);
}
}
}
while (true);
for (/*int*/ i = 0; i < MAX_SERVERS && cfig.tftpConn[i].server; i++)
closesocket(cfig.tftpConn[i].sock);
WSACleanup();
}