osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Checking refusal of a network connection


On 2019-06-01 19:15:28 +0200, Markus Elfring wrote:
> >> connect(3, {sa_family=AF_INET, sin_port=htons(37351), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 ECONNREFUSED (Connection refused)
> > 	Without seeing the code, I'd be suspicious of that difference.
> 
> I would expect that the IPv4 address from such a connection attempt
> would be automatically converted to a IPv6 loopback address.

You haven't said which OS you are using, but as far as I know this
expectation will be frustrated at least on Linux: There ::1 and
127.0.0.1 are distinct addresses. If you want to accept connections on
both, you have to listen on both (or on ::, which does accept
connections on all IP addresees - IPv6 and IPv4).

        hp

-- 
   _  | Peter J. Holzer    | we build much bigger, better disasters now
|_|_) |                    | because we have much more sophisticated
| |   | hjp at hjp.at         | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20190601/07b9f144/attachment.sig>