Boost logo

Boost Users :

Subject: Re: [Boost-users] Server application won't bind to ports on IP address other than my internal ones
From: Leon Mlakar (leon_at_[hidden])
Date: 2019-01-12 17:22:53


On 12.01.2019 12:30, Osman Zakir via Boost-users wrote:
> I was also told that the problem could be either my network
> environment, something in my code, or both, and I was just giving info
> to help with figuring out which one it might be.  And notice that I
> did also ask about a problem with building Boost, too.

Now, to ultimately check where the problem is, here's a homework for
you. Write the code using the plain sockets (WinSock2 on Windows) that
binds the TCP socket to the address you wish to bind your acceptor to. 
If the bind doesn't fail, it is a problem with the boost library, and
return here for more help.

If the bind fails, it is a problem outside the boost library. In this
case, first read the following, then read some network introduction
books and then seek help on network forums.

IP addresses you see from outside your local network (possibly from the
Internet) are typically not the IP addresses that belong to  your local
computer but are NAT mapped by some router in your environment. You
mentioned that you computer has loopback and a network interface with an
IP address in range 192.168.x.x. That's typical home environment. The
latter address is a private number belonging to your private network and
is not visible from outside, hence some piece of equipment in your
environment is mapping this private number into external IP address
(usually assigned by ISPs).

Generally, you cannot reach a computer behind the router that uses NAT
from the outside using the externally visible IP address. Unless you
configure the router properly.

You cannot bind a socket to the IP address that is not an IP address of
a network interface on your computer.

When calling bind, unless having a very good reasons against it, one
typically binds to INADDR_ANY (IP address 0.0.0.0) which binds a socket
to all network interfaces on  your local computer.

Good luck

,

Leon



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net