Skip navigation

I had this problem that kept coming up again and again, so I’m recording it here.

The problem is when you have a server that listens for UDP packets. Its fine, its open, no firewalls are causing issues at that end. Say its at

Now, you want to connect to that server using a UDP sockets program on your local machine. Because you have a firewall, you need to DICTATE from which IP:Port your local sockets program will send sockets.

So naturally, you first go to your firewall software (in your router) and you open port 10007 on (which is your IP address assigned to you by your router).

Now from your client sockets program, you send UDP packets out on a UDP socket which is bound to

It doesn’t work.


Even though the UDP socket is being sent from “THIS MACHINE” (which is probably what you intended when you used the loopback), LOOPBACK != EXTERNAL IP ADDRESS!!

Sending data from the loopback address is actually completely different to the router.. than sending data from your externally assigned ip address. So, yes, if you are connected to the internet, your computer DOES have minimum 2 ip addresses (loopback and the external ip address the router gives you). Actually it has 5:,,, are all loopback. Then the external ip (which for me was

OK!! So how do you fix it?

You bind the UDP socket to


bind it to (IPADDRESS.ANY, 10007) (like,


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: