Networking Fog Continues...

Just starting out? Need help? Post your questions and find answers here.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Networking Fog Continues...

Post 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.
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post 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
Tranquil
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post 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!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post 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
Tranquil
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Ahhh gotcha Mike, thanks!@!

Looking forward to that example!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Post Reply