Connection Fail

myConnection = cManager.openTCPClientConnection(ip,port,timeout)

So ive got a little network game… it doesnt do much yet but you can see yourself and other ppl moving around in a big vast nothingness

Now the client/server connection worked fine while i had the ip set to local ips (because i have a router)

However, when i set the ip to the public address and set up port forwarding the connection fails…
I dont understand what could be causing it to fail… the port forwarding is set up right

I dont know if this really belongs in this forum but any help would be very nice

well honestly it is very difficult to help you out with such a small infos provided. The better I can do for you is to show you a forum page (try to digg it for yourself next time though before to ask) where to find working network code to compare yours: click here to go there.

trust me i did try to look for stuff…
However, i think i may have solved the problem
Wont be sure til tommorrow and i will probably be wrong

But im pretty sure its not a problem with Panda… more likely a problem with the router

Thanks tho!

to check if you really receive packages you can use a tool like wireshark ( ), it’s not easy to use but it can help debugging network problems of any type as it will show you each package you received including it’s data.

one thing that comes into my mind:
port forwarding needs to be setup on the other computer you want to connect to. so if you have setup port forwarding on your router you cannot connect to the other host unless he sets up port forwarding as well…

oh and another thing:

if you want to use UDP you have to setup port forwarding on both hosts (unless you use some special method/code ( ) ).

for TCP it’s sufficient to have the receiving hosts port forwarding setup.

hmmm… thanks hypnos

i think ive got the problem solved though

->the client sends a connect request to the server on port 9099
->the router sees the port number and automatically forwards the packet to the computer which the server is set up on
->then the server sends back a connection confirmation on port 9099 (because the server is receiving the connect request)
->the router sees the port # once again and forwards this confirmation back to the server
=>SO the client doesnt ever get the confirmation and the connection fails

AND my router wont let me forward the same port to two computers
so pretty much i just cant have the client and server connected to the same router unless i spwcify local addresses

if you create a outgoing connection the outgoing port number is chosen randomly, it’s only the incoming port (server port) number that is fixed (defined by you). the server then connects back to the client using the ip-adress seen and it’s port number. so it should be possible to setup such a connection within the home network (using the external ip adress).
(this concept is also used you run client and server on the same computer. sidenote: there may be only one application running on a port)


  • client creates connection from random port (34567) to server ip and port 9099.
  • server accepts connection and uses the client’s ip and port to communicate to it.
  • the router may modify the port number which the client uses during the NATing (network address translation).
  • this randomly selected port of the client does not need a port forwarding, the NAT does setup this forwarding automatically when it see’s a outgoing connection.

depending on the router you use, you can specify how the port forwarding is done, (does it communicate back to the router or to the public ip of the client). most probably you can’t specify this in your router (it’s possible in professional firewalls, for example using a linux firewall with iptables) and it may just be impossible to define this correctly on a consumer router.
BUT, usually they are setup so this should work…

and yes, you cannot forward a port number to multiple ip’s. it would be impossible for the computers to know what is meant to be received by each of them. it’s actually possible, but is only used in very specific setup’s, like load balancing and high availability systems.

i hope this helps and doesnt increase confusion :slight_smile:

Thanks Hypno! ill keep all that in mind…
The program worked fine from another network connecting to mine however so yeah idk … its sumthin witht the router