My problem is that when I already have a TCP connection (FD_ACCEPT on the
server side, FD_CONNECT on the client) the client continues to get
FD_CONNECT with a few seconds interval. Does anybody know what's going on
here.
Below is an excerpt from my code:
/*static*/ UINT CAsyncSocket2::EventThread(CAsyncSocket2* pThis)
{
CSingleLock lockEndThread(&pThis->m_eventEndThreads);
CArray<WSAEVENT, WSAEVENT> arrayEvents;
arrayEvents.SetSize(1);
arrayEvents[0] = pThis->m_hEvent;
WSANETWORKEVENTS Events = { 0 };
DWORD dwWaitResult = 0;
BOOL bRun = TRUE;
while (bRun)
{
if (lockEndThread.Lock(0))
{
bRun = FALSE;
}
else
{
switch (dwWaitResult =
::WSAWaitForMultipleEvents(arrayEvents.GetSize(), arrayEvents.GetData(),
FALSE, 100, FALSE))
{
[intentionally left out trivial code for other cases]
case WSA_WAIT_EVENT_0:
//TRACE("WSA_WAIT_EVENT_0\n");
::ZeroMemory(&Events, sizeof(WSANETWORKEVENTS));
if (0 == ::WSAEnumNetworkEvents(pThis->m_hSocket,
arrayEvents[0], &Events))
{
if (FD_CONNECT == (Events.lNetworkEvents & FD_CONNECT))
{
pThis->OnConnect(Events.iErrorCode[FD_CONNECT_BIT]); //
Keeps coming and coming and coming....
}
[intentionally left out trivial code for other events]
break;
[contd.]
Thanks for any enlightment in this annoying situation.
/Stefan
Claes Bergefall
cl...@prosolvia.se
Stefan Rådström skrev i meddelandet ...
/Stefan
Claes Bergefall skrev i meddelandet ...
>Did you create the event with WSACreateEvent?
>If so, you need to reset it with WSAResetEvent
>after you've handled it.
>
>Claes Bergefall
>cl...@prosolvia.se
>
>
>Stefan Rådström skrev i meddelandet ...
>>Hi all!
>>
>>My problem is that when I already have a TCP connection (FD_ACCEPT on the
>>server side, FD_CONNECT on the client) the client continues to get
>>FD_CONNECT with a few seconds interval. Does anybody know what's going on
>>here.
[snip]