Click to See Complete Forum and Search --> : Public IP talks to Private IP / Private IP to Private IP in another location
kert30
November 27th, 2007, 06:56 PM
Hi Buddies,
I have been thinking about this for a long time, How can I do (either in C, C++, .NET) in order to
1. Make a host with a Public IP talks to a host with a Private IP(behind a public IP)
2. Make a host with a Private IP talkes to a host with Private IP in another location
It seems that both RPC and winsocket cannot realize it.
It is will be really useful to make a live chat application or for some online games since people may use different network connections.
Any help will be highly appreciated!
dglienna
November 27th, 2007, 07:22 PM
You start with an open port (80 usually) and then detect which ports are open, and have the client switch to those ports automatically.
That's how chat apps work. I can log in to ANY computer in the world, over a SECURED connection, started over port 80
kert30
November 28th, 2007, 01:11 AM
Thanks for your reply! But what if the client is behind a router and is assigned a private ip address.
for example:
client ip is 192.168.1.100 and
The ip of router connecting to the client is 146.167.22.202 (some public ip address and usually the rounter will have two ip addresses, one is private, the other is public
How can other hosts in the internet push or send data to this client?
MikeAThon
November 28th, 2007, 11:09 AM
The router is responsible for routing an incoming request from a public IP address to a private IP address behind the router.
The process is called network address translation (NAT) and port mapping.
To do what you want, you simply need to configure the router properly. For outbound connection requests (i.e., from a private IP address behind the router), there's nothing to do since all routers handle this correctly. For inbound connection requests, i.e, where a private IP behind the router must accept connections from a public IP, you must configure the router with an appropriate port mapping.
Mike
kert30
November 28th, 2007, 11:22 AM
Thank you for your reply!
I notice some softwares like windows messenger, no any router configuration is required in order to communicate between private ip to private ip over internet, what is under the hood?
Also, like VNC server, I think it is based on WinSocket, to communicate between private ip to public ip over internet, no router configuration is required, does that mean Winsocket connection will work for this situation without any further action?
MikeAThon
November 28th, 2007, 02:11 PM
I notice some softwares like windows messenger, no any router configuration is required in order to communicate between private ip to private ip over internet, what is under the hood?
Two possibilities:
First, many programs make only outgoing connections, and thus are all "clients". For example, a chat program might work through a centralized server, to which all clients connect. Thus, there is no need for any of these programs to configure a router so as to accept incoming connections.
Second, if the program accepts incoming connections (like most Torrent clients, for example) the router might be configured programmatically, using universal plug-n-play (UPnP).
Mike
Lindley
November 28th, 2007, 02:12 PM
If no configuration is required, that simply means that the connection is initiated from the private IP. In the case of chat clients, it connects to a public server somewhere else.
You can think of a router that has private IPs behind it as a port mapper. If it receives an outgoing connection request packet from a given private IP and port, future incoming packets for that port will be routed to that private IP. Or that port -> private IP mapping can be established manually.
But if the router receives a packet bound for a port that it doesn't know what to do with, it can't forward it anywhere.
Winsock (and Unix sockets) only understand a few types of addresses. The most common one is sockaddr_in, which only contains an IP and port (assuming IPv4). How or if that packet reaches said destination is outside winsock's control.
codeguru.com
Copyright 2007 Jupitermedia Corporation All Rights Reserved.