PDA

View Full Version : use CL_Socket in ClanLib 0.8



silekey
07-10-2007, 08:42 AM
use in windows xp, VC 6.0

the problem is i close the socket wait too long.

test code:
CL_Socket sk(CL_Socket::tcp);
sk = CL_Socket(); //close socket,but it's wait long time.

i think reason in socket_generic.cpp : 291
WSAWaitForMultipleEvents(1, &event_object, FALSE, 60*1000, FALSE);

Seth
07-10-2007, 10:00 AM
Hi, you are right - I fixed (well, ok, hacked around) this problem after the 0.8 release.

Can you switch to using the SVN 'in development' 0.8?

Here is how the file is now commented in the SVN version:


//the code below causes a one minute deadlock when closing a socket - (might be only sockets
//that are not bound yet, this happens with the copy constructor when initializing
//in CTalk. Maybe we should set a flag for when a socket is actually bound? And even in that case,
//build a blocking thread to do this so we can return right away?
//Let's keep it disabled for now, Magnus has said he has a fix coming in 0.9 that we can backport.
//-mrfun Sept 22 2006

/*
// Must stop and wait for all send data to be sent (thanks Microsoft):
HANDLE event_object = WSACreateEvent();
if (event_object != WSA_INVALID_EVENT)
{
if (WSAEventSelect(sock, event_object, FD_CLOSE) != SOCKET_ERROR)
WSAWaitForMultipleEvents(1, &event_object, FALSE, 60*1000, FALSE);
WSACloseEvent(event_object);
}
*/