Page 1 of 1

Networking Fog Continues...

Posted: Wed Jun 25, 2003 8:48 pm
by Karbon
OK, I'm going cross-eyed trying to figure out what is the "correct" way to do this networking stuff.

Is the correct way to deal with network events to use NetworkServerEvent() and NetworkClientEvent() or to do it in a callback like?

I have examples from the PB manual using NetworkServerEvent() but a lot of the posts in the forum and people I've talked to say to use a callback because the network events aren't properly reported... Needless to say I'm confused as to who/what is right.

So, do the Network*Event() functions work, or no, or am I asking the wrong question there :-)

Many thanks to Tranquil for bouncing emails around with me.

Posted: Wed Jun 25, 2003 10:29 pm
by Tranquil
You need this commands too to figure out what happened.
The callback only tells you that something has happened. Not WHAT exactly happened.

Sadly it is not possible to assign more then one message to a socket using WSAAsyncSelect_(). You can only tell Windows which messages you want to receive and which not.

Mike

Posted: Wed Jun 25, 2003 11:31 pm
by Karbon
Hiya Mike, thanks for the reply..

If that's true that you need the callback to know something happened then I'm not sure I understand why my code *seems* to work without it. The code I have currently is only handling one connection at a time. Would I start seeing crazy stuff if multiple people connected and such?

I'm using this :

Code: Select all

#FD_ALL = #FD_READ|#FD_WRITE|#FD_OOB|#FD_ACCEPT|#FD_CONNECT|#FD_CLOSE
WSAAsyncSelect_(l_socket, WindowID(), #WM_NULL, #FD_ALL) 
.. in there now, but I have a feeling I'm only going to see the benefit of that (and maybe the callback) if I'm dealing with sending/receiving data on multiple connections at the same time..

Thanks again!

Posted: Thu Jun 26, 2003 11:38 am
by Tranquil
If you not do the EventHandling in your callback and there are incomeing datas on the receive-socket this message is not reported if you move the window or resize it at the same time. This is due to the behavior that PB filters events to the WaitWindowEvent() command.

I will send you a small server/ client source code when I'm at home. Its a little chat client which shows networking in general.

Cheers
Mike

Posted: Thu Jun 26, 2003 3:05 pm
by Karbon
Ahhh gotcha Mike, thanks!@!

Looking forward to that example!