Very basic socket question

DiscoJimmy

Newcomer
Joined
Oct 16, 2003
Messages
8
Ok, I think this probably a very basic question. I'm a C#/VB.NET programmer who knows very little about network communications. I've managed to hack out a chat application based on Sockets. I made another based on TCPClient/TCPServer classes that ran the same way. The problem is that it only works over my office network. I've been using the local IP's (10.0.0.5 etc.)
Is it possible to talk to these ports when you're outside the LAN? If I get the IP address of the network, and I know the local IP, what do I do? The network has no proxy, and is just a couple of computers and a router(or maybe hub).

Thanks in advance,

DiscoJimmy
 
You probably have a firewall / NAT or similar between you and the Internet as 10.x.x.x address are not valid for use outside the local network.
This could be made to work but for external clients comming in the firewalll would have to be configure to forward the relevant ports.
 
ok, assuming I can forward the ports(which i also don't know how to do), what would the code be like? I've always been using things like:

IPHostEntry ipHostInfo =Dns.Resolve(etc)
IPAddress ipAddress = ipHostInfo.AddressList[0];
remoteEP = new IPEndPoint(ipAddress, 11000);

where does my local IP come in? what i mean is, I can only specify 1 IP address with this type of code, and I assume that would be the router's IP. how would I then specify a particular computer on that network?

Thanks,

DiscoJimmy - oh, and if you could give me a hint on forwarding those ports, that would be cool too - it's a Linksys 4 port Router
 
If you are contacting computers over routers / firewalls / NAT etc the forwarding of packets is their problem.
You would still use the IP address of the machine you need to connect to, it would require the overall TCP/IP infrastructure to be configured correctly to allow the packets to reach their destination.
 
Back
Top