Problem with IP selection Socket Programming C# -



Problem with IP selection Socket Programming C# -

i creating server (desktop based) listens on port 4504 using bit of code

ipaddress[] addressar = null; string serverhostname = ""; seek { serverhostname = dns.gethostname(); iphostentry ipentry = dns.gethostbyname(serverhostname); addressar = ipentry.addresslist; } grab (exception) { } if (addressar == null || addressar.length < 1) { homecoming "unable local address ... error"; } listener_socket = new socket(addressfamily.internetwork, sockettype.stream, protocoltype.tcp); listener_socket.bind(new ipendpoint(addressar[0], port)); listener_socket.listen(-1); listener_socket.beginaccept(new asynccallback(endaccept), listener_socket); homecoming ("listening on " + addressar[0].tostring() + ":" + port + "... ok");

now problem that, want run on server , value of addressar[0] want public ip of server, snippet returns local lan address of server.

like want addressar[0] = "180.123.45.6" [which public ip of server], snippet getting addressar[0] = "192.168.2.2"

ps: running server desktop app , trials in debugging mode.

i'd appreciate help. give thanks you.

you need hear on local host, 192.168.2.2 (this correct) , forwards external packets/traffic public address local machine.

if you're using, instance, linksys router, can go nat/qos , forwards incoming traffic on specific port, e.g. 4504 local machine address 192.168.2.2

any standard home router have port forwarding built firmware.

c# sockets networking network-programming

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -