Search code examples
pythonpython-3.xidl-programming-language

what dose socket.INADDR_* do


I have an issue with socket.INADDR_* constant of Python socket I cant understand what dose these constants do? For example:

socket.INADDR_LOOPBAD
socket.INADDR_RESERVED

What does the above options do?


Solution

  • Those constants refer to IP addresses. Refer to your system Unix documentation for what they mean, as indicated in the Python documentation. I don't think socket.INADDR_LOOPBAD or socket.INADDR_RESERVED are real constants.

    A few common constants are:

    • INADDR_LOOPBACK (127.0.0.1) - your local host, via a special network device known as the loopback device
    • INADDR_ANY (0.0.0.0) - any address used for binding (accept connections to any IP on the machine)

    The IP manual has more useful information on these constants.