Sneaky UDP Failure

BlitzMax Forums/BlitzMax Beginners Area/Sneaky UDP Failure

spacerat(Posted 2007) [#1]
Hello Blitz community!
I am having some troubles concerning UDP connections. I have a Server, Client, and some extra functions (to actually run it download them all (addresses at bottom of post...)and change the txt's to bmx).
It would help if you test the files too so you can see what I mean (they are part of something bigger so you may have a bit of rubbish to filter through).

Basically, the TCP connection between server and client works fine, press characters in the client, they get sent to eh server then back to the client. HOWEVER, the UDP stream only seems to work from client to server, the either the server isn't sending back correctly, or the client isn't reading correctly. Either way, the client is receiving no UDP traffic.

The way it works at the moment is that the client binds the UDP port to the same port as the TCP port (it picks it's own port) then the server finds and connects to the UDP port the client is using, by checking the TCP port of the client.

I would appreciate any help you can give, even just a plain old example of how to use UDP and TCP together with a server and client.

http://spacerat.meteornet.net/Server.txt
http://spacerat.meteornet.net/Client.txt
http://spacerat.meteornet.net/functions.txt


Dreamora(Posted 2007) [#2]
That won't work.

Unless the client sent a message to the server first (which has portforwarding on that udp port) you will not be able to send the client anything as TCP and UDP are not handled as one by the NAT.

-> client has to contact server first if server wants to answer and it has to be on the same protocol as long as the incomming udp port has no static forwarding (or triggered one basing on the tcp port) to the desired system.


spacerat(Posted 2007) [#3]
I'm not great with the technical words involving TCP and UDP so bear with me.
Port forwarding and stuff like that is not so much of a problem at the moment, since I am either testing on a single machine with client and server open, or over a LAN.

"Unless the client sent a message to the server first"

The client is sending both TCP and UDP messages to the server. Perhaps I am not understanding you correctly or perhaps I didn't explain myself right.
The client connects a TCP socket to the server, and a UDP port to the server. The server accepts the TCP socket, then connects back to the client's UDP socket. Then the client starts sending stuff on TCP and UDP. The server picks them both up and sends TCP and UDP back. The problem lies in that the client only receives TCP from the server at this point, not UDP.