X
X
xverizex2020-02-26 04:47:33
C++ / C#
xverizex, 2020-02-26 04:47:33

How to do or how does listen localhost work?

Here in some programs you can specify such a listen that it will only listen to its own machine. Is there such a function? Or is it not necessary to bind to the address 0.0.0.0? Or, after connecting, compare the client address and if it differs from 127.0.0.1, then reset the connection. I think that probably it is necessary to do bind on 127.0.0.1, but is it so?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2020-02-26
@jcmvbkbc

I think that probably it is necessary to do bind on 127.0.0.1, but is it so?

Yes. INADDR_LOOPBACK -- there is a special macro for this address.

V
Vadim Priluzkiy, 2020-02-26
@Oxyd

The local interface, aka localhost, has the address 127.0.0.1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question