Hello all,
I am writing a client server socket application for Windows Mobile 5.0.
In my client application, I am creating a socket and trying to connect as
follows (have removed debugging code):
hSocket = WSASocket ( AF_INET, SOCK_STREAM, 0, NULL, 0,
WSA_FLAG_OVERLAPPED);
if(hSocket == INVALID_SOCKET)
{
//Error code
}
if(bind (hSocket, (sockaddr *)&sockAddr, sizeof(sockAddr)))
{
// Error code
}
hNotifEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
if (hNotifEvent == NULL)
{
// Error code
}
if (WSAEventSelect (hSocket, hNotifEvent, FD_CONNECT))
{
// Error code
}
if (WSAConnect (hSocket, (sockaddr *)&sockAddr, sizeof(sockAddr), NULL,
NULL, NULL, NULL))
{
// Error code
}
The problem is that even I am calling WSAEventSelect() to associate the
event object with FD_CONNECT for the hSocket, the call to WSAConnect()
executes in blocking mode and if the server is down (not listening) then the
call to WSAConnect() is blocked for a couple of second till it returns
error.
Is this normal behaviour? Because I was expecting the call to WSAConnect()
to return immediately and an then I was thinking to wait on the event object
to get the result of connect call.
Or is there anything that I am missing? Any thoughts.
Thanks,
Arsalan
Archived from group: microsoft>public>pocketpc>developer>networking