IP for network computers

ImDaFrEaK

Well-known member
Joined
Jan 7, 2006
Messages
416
Location
California
Programming Experience
5-10
I am a noob for network programming. I have maybe a stupid question. I have been able to get my computer to communicate via ip, however; now I have a home network in which the router is the owner of the ip i guess. Does each computer attached to the router now have it's own IP address? And if so, is this the address I give to another computer around the world to use? I'm a lil lost but any info will help.
 
Routers usually got DHCP that give each local computer a local network IP address, while the router itself receives one IP from the ISP. For this basic setup all local machines are seen with the common IP outside the router.

For applications where they have to connect to your public IP, you usually open (default security is closed) a route by the router for connection of a local IP and port.

For instance you may have public address x.x.x.x, two locals y.y.y.2 and y.y.y.3, a local FTP server at y3. For public to connect to your FTP at x.x.x.x you will configure the router to route incomming requests to port 21 to the local y.y.y.3.
 
Can this be done by code in the program? Basically I want to build a messenger as a sample program. I want the messenger to work peer to peer. I type in their IP and port and they do the same. But will they have to setup up their router also everytime? Or did i confuse what you said a lil bit.
 
Routers have made it easier to share an internet connection so everybody behind it can get out easy (and be commonly protected), small home networks is getting more popular, but it have also made it more difficult when needing to connect from the outside to a specific computer behind the router. You do understand that from the outside all these local computer share the same public IP? (check with a public service like http://www.whatismyip.com ) So when trying to connect to one of these, the router have to do its job and route that request to the determined computer. This is done by mapping certain ports to specific local IP addresses, and different applications always makes call at these certain ports, where 'server' listens. This is how P2P have to be done in network terms, one of the 'points' have to be server and the other client. So if server is behind a router then that one have to enable a route for it to work. Setting up the network equipment can't be done in code as I know.

Regarding Messenger there is a public server each client connects to first, then server looks up your contact list to see if they have logged in to server. Actually it's not P2P, all messages go through that server. In this case client connects to and tells server it's online, for a chat session sends messages to server then polls to see if messages are available. That way the server never tries to connect to client, and router-problem is not an issue. (Still there may be firewalls that may have to be opened for communication to work)
 
K, i think i understand but let me sak a question. If i have 4 computers on a home network and 1 computer claims port 50000 then will this port also be taken from the other 3 computers on the same router? I am still a lil confused, please don't get mad, I really really appreciate all the help.
 
ok, that's really cool. So maybe I can designate one port only for one pc and make that one my server, then let the rest talk through it and it will assign the ports to each computer. Question is, can I find what port the client computer is sending information through w/o writing code for them to send me that information such as remoting or somthing. Like when I do getStream will it retrieve port information for me as well from the client ect.... Thanks a ton, this helps alot!
 
Back
Top