UDP port help needed

Blitz3D Forums/Blitz3D Programming/UDP port help needed

slenkar(Posted 2007) [#1]
I used a demo from the code archives of a UDP chat program,
on 2 seperate computers.

http://www.blitzbasic.com/codearcs/codearcs.php?code=876

the server computer used port 4000 and the client used port 4001 with the createUDPserver command

whenever I used the same port (4000) for both PC's the messages could not be recieved. But it worked if they used different ports.

This makes things very difficult because I have to keep track of what port everyone is using and make them all different.



Has anyone experienced this before and come up with a solution?


Carolinaaa(Posted 2007) [#2]
I work well with udp messages using the same port in the server and client. I use an unique port for both sending and receiving messages, and the port number is the same in the client and server.


I suggest you use the udpstreamport command on the server to know the port of the incoming message and then reply to that message to the same port provided by udpstreamport, even if you think that it is 4000, some routers change the port and if the server answers directly to the port 4000, the router will block that message, so the server has to reply to the port obtained with the command udpstreamport. Have this in mind if you want to avoid lots of headaches in your future development of net applications. This problem happens with lots of routers and most of people use now routers.


slenkar(Posted 2007) [#3]
thanks Ill try that out