|
-
April 7th, 2008, 05:04 PM
#1
Winsocks and Public IP
I had a thread a while back about winsocks and connecting them through LAN, which worked! http://www.codeguru.com/forum/showthread.php?t=446639 (that thread contains the code for server/client)
My program listens on port 6980, and again, can send data between client and server successfully when on a LAN. I am attempting to get the server to accept connections from other computers that aren't on the network. The problem is, whenever the client attempts to use my public ip, even if the client and server are on the same computer, it still won't connect. I have forwarded my ports and added port 6980 to exceptions in firewall, and it is still yet to work.
Has anyone had any success in getting their server program to allow connections from clients outside of the LAN? And if so, how?
-
April 8th, 2008, 09:46 AM
#2
Re: Winsocks and Public IP
 Originally Posted by tophat
... The problem is, whenever the client attempts to use my public ip, even if the client and server are on the same computer, it still won't connect. I have forwarded my ports and added port 6980 to exceptions in firewall, and it is still yet to work.
The "public IP" is not the IP address of the computer; it's the IP address of your modem/router. So, attempting to connect to the public IP address from inside the same machine can't possibly work.
It also is not likely to work if connecting to the public IP from any machine inside the local network. There is one exception that I am aware of: it might work if the router supports hairpin routing. But few do.
The public IP is there for the public. If your port forwardings are set up correctly, then members of the public out on the Internet will be able to connect to you by use of the public IP address. Members of the private LAN will not be able to connect to you using the public IP address; they will need to use the local LAN IP address.
Mike
-
April 8th, 2008, 09:06 PM
#3
Re: Winsocks and Public IP
Thanks, Mike. I have finally got this to work. I first reset my router, just because I had some settings changed that were effecting my network. I tried re-adding the port to the forward list and a friend was able to connect to my computer remotely. But, this can be difficult for someone with very basic computer knowledge to figure out, so I was wondering if you knew how to forward ports by using the Win32 API, or if there is even a way to bypass this need all together?
-
April 9th, 2008, 04:06 AM
#4
Re: Winsocks and Public IP
There is no standard way in which a router/firewall manufacturer has implemented the user interface for the port forwarding. This means that there is no API that you can use on a local network computer that is compatible with all brands and models of router out there.
If the router supports the SOCKS protocol then you may be able to open up a port on the router in a dynamic way, but there are not many routers that do support it I'm afraid.
At the moment setting up port forwarding (or "application sharing" as some router manufacturers now call it) is just part of normal network maintenance.
-
April 9th, 2008, 09:46 AM
#5
Re: Winsocks and Public IP
I tend to disagree. Many routers today support UPnP, which can be used universally to map ports, regardless of the router's origin.
For one example, see "Using UPnP for Programmatic Port Forwardings and NAT Traversal" at http://www.codeproject.com/KB/IP/PortForward.aspx
With respect to another issue that's difficult for novice end users, it is also difficult for them to remember public IP numbers, rather than alpha names, and the public IP numbers often change anyway if your ISP assigns a dynamic IP each time you log on. For this, I would recommend a dynamic DNS service (DDNS). Search here for DDNS and you will find a few providers, many of which are free.
Using DDNS, your end-users will be able to type a name like tophat.yi.org, instead of remembering an IP number.
Mike
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|