VB6: Networking Problems
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
VB6: Networking Problems
Hi everyone,
I'm making a game in VB for a school project and it uses networking for a multiplayer mode. The game itself is working well, with a map system and everything just works. However, I'm having some serious trouble with networking.
For my testing I run the server program and two clients. The two clients connect to the server, and the server sends the MOTD. This works perfectly. The first client receives broadcast packets properly and can see the second client moving. The second client can't receive them properly. I have a chat system implemented, and the second client will only ever receive a broadcast packet after a couple of chat messages have been sent to it. From then on it requires chat messages to "unblock the pipes" and let the broadcast packet through.
The broadcast packet just holds information about a specific player (specified by an ID) to be stored locally until the next broadcast.
Any ideas as to why I'm having trouble with the second client would be great. I've been working at this one bug for about two weeks now and school ends soon.
I'm making a game in VB for a school project and it uses networking for a multiplayer mode. The game itself is working well, with a map system and everything just works. However, I'm having some serious trouble with networking.
For my testing I run the server program and two clients. The two clients connect to the server, and the server sends the MOTD. This works perfectly. The first client receives broadcast packets properly and can see the second client moving. The second client can't receive them properly. I have a chat system implemented, and the second client will only ever receive a broadcast packet after a couple of chat messages have been sent to it. From then on it requires chat messages to "unblock the pipes" and let the broadcast packet through.
The broadcast packet just holds information about a specific player (specified by an ID) to be stored locally until the next broadcast.
Any ideas as to why I'm having trouble with the second client would be great. I've been working at this one bug for about two weeks now and school ends soon.
An idea and a question:
Are the chat messages and packets send on the same port? If so, it may uncomplicate things a bit by having separate ports for separate protocols. Just a thought.
..and the question: Do you have any way of telling if the server is sending out the data to the second client correctly, or is it at the client end?
Cheers,
Adam
Are the chat messages and packets send on the same port? If so, it may uncomplicate things a bit by having separate ports for separate protocols. Just a thought.
..and the question: Do you have any way of telling if the server is sending out the data to the second client correctly, or is it at the client end?
Cheers,
Adam
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Problem is, to have multiple ports would require multiple Winsock controls and a lot more management code (which complicates things further)...
The server, when it is broadcasting, prints to a console. I can see that it is sending to everything properly, it's just the client that isn't receiving it properly.
The thing that really confuses me is why the broadcast packets are only read after a couple of chat messages are sent? Are they in the queue but not read (which I doubt, because VB6 is event based and I do have an event handler for DataArrival), or is something happening elsewhere?
The server, when it is broadcasting, prints to a console. I can see that it is sending to everything properly, it's just the client that isn't receiving it properly.
The thing that really confuses me is why the broadcast packets are only read after a couple of chat messages are sent? Are they in the queue but not read (which I doubt, because VB6 is event based and I do have an event handler for DataArrival), or is something happening elsewhere?
Sorry for the bitty replies - I'm just putting down thoughts as they come to me. I wrot a network management program years ago in VB5 - but am a little rusty now!
What happens if you disable the chat system for a moment (from the server and client ends)? Does that mean you get the other packets through? I just wonder if you have some kind of logic error rather than a socket error - perhaps you are examining a packet for a control character which isn't coming through when expected or something along those lines? I agree that it would be odd that Client 1 would still be working in that situation, though...hmm...
What happens if you disable the chat system for a moment (from the server and client ends)? Does that mean you get the other packets through? I just wonder if you have some kind of logic error rather than a socket error - perhaps you are examining a packet for a control character which isn't coming through when expected or something along those lines? I agree that it would be odd that Client 1 would still be working in that situation, though...hmm...
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Winsock controls suck, use the good ole' interface. With a bit of effort they are better and more bug free than those vb implementations that break half of the time.
That and you can then use setsockopt with TCP_NODELAY to disable nagle's packet merging algorithm. (and other good things like non-blocking read calls)
Speaking of which, I think I just found my IRC bot's nagleing bug
That and you can then use setsockopt with TCP_NODELAY to disable nagle's packet merging algorithm. (and other good things like non-blocking read calls)
Speaking of which, I think I just found my IRC bot's nagleing bug
- Attachments
-
[The extension bas has been deactivated and can no longer be displayed.]