tags:

views:

396

answers:

2

Hi all

I am trying to run client server UDP program . My both machines are in different networks. I have set up port forwarding in my router.

My server has two IP Address : 1) External 200.?.?.? 2) Internal 192.168.0.100

While creating UDP server I need to create a socket which is binded to addresss.

What address should I bind socket to, external or internal?

I tried with internal address but it is not getting any data from client.

Suggestions...

A: 

Given the fact that you said you set up port forwarding, did you assign the proper ports within the UPD program? or are you just sending data to an IP address? If you specify the External IP address and a port number, the port forwarding on your router should send it to the appropriate node on the network.

John T
yes I have set port 15500 in both client and server and same port number in port forwarding...In server I am creating recviever address asrecvAddr.sin_addr.s_addr = htonl(INADDR_ANY);should I give INADDR_ANY or external IP?
Alien01
A: 

If you must bind to a specific address, then it would be the internal address and definitely not the external address.

The whole point of the NAT on your router is to hide your internal network addressing scheme from the outside world. The router's NAT algorithm will take care of re-writing the destination IP address on any inbound packet to the correct internal IP address.

That it's not working suggests that there's something wrong with your port forwarding and/or firewalling on the router. It's not uncommon that you'd need to set up a specific firewall rule to permit the traffic in addition to the forwarding rule.

Alnitak