mspocketpc.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Why Blocking WSAConnect..even when WSAEventSelect() is alrea

 
Post new topic   Reply to topic    mspocketpc.org Forum Index -> Developer Networking
Author Message
Arsalan Ahmad



Joined: 15 Aug 2007
Posts: 8

PostPosted: Tue Aug 28, 2007 4:46 pm    Post subject: Why Blocking WSAConnect..even when WSAEventSelect() is alrea Reply with quote

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
Back to top
View user's profile Send private message
Waleri Todorov



Joined: 29 Aug 2007
Posts: 1

PostPosted: Wed Aug 29, 2007 2:57 pm    Post subject: Re: Why Blocking WSAConnect..even when WSAEventSelect() is a Reply with quote

Q2hlY2sgaW9jdGxzb2NrZXQoKSwgRklPTkJJTw0KDQpXU0FfRkxBR19PVkVSTEFQ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FsbC4NCj4gDQo+IE9yIGlzIHRoZXJlIGFueXRoaW5n
IHRoYXQgSSBhbSBtaXNzaW5nPyBBbnkgdGhvdWdodHMuDQo+IA0KPiBUaGFua3MsDQo+IA0KPiBB
cnNhbGFuIA0KPiA=
Back to top
View user's profile Send private message
Arkady Frenkel



Joined: 15 Aug 2007
Posts: 17

PostPosted: Wed Aug 29, 2007 5:02 pm    Post subject: Re: Why Blocking WSAConnect..even when WSAEventSelect() is a Reply with quote

Why you use bind() for client, that for servers only
Arkady

"Arsalan Ahmad" wrote in message @microsoft.com...
> 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

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Problem with non-blocking socket I've got the following very simple non-blocking socket. I am seeing a problem where instead of receiving I am CONSTANTLY receiving an error number of 183 which corresponds to It seems as if 183 is being returned ins

Blocking Numbers Is there any way to block calls on a Samsung i600 with the 2003 operating system? I know I can turn flight mode on or lock the phone but I'm talking about actually blocking outgoing calls entirely, blocking incoming calls entirely, or b

Caller Number / Call Blocking hi i m new to Pocket PC development i would like to know how to get the Incomming Call's Phone number, and how to Cut off that incomming thanks

Active Sync Notes data field blocking sychronisation I have recently upgraded? to a jasjam smart phone from an HP iPac. Syncing worked just fine with the iPac. However , when I try to sync the jasjam, any contact or diary entry that contains data in the notes field won't synchronise from the PC. This is a m

Mpx220 I have a Mpx220 phone and when I try to sync it up with activesync I get an error that says "Sync status is on the device." I am running Outlook 2000-sr-1 and activesync 4.2. My book calls for activesync 3.71 or later. I need to sync up everything. TIA
Post new topic   Reply to topic    mspocketpc.org Forum Index -> Developer Networking All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group