Home > Enterprise >  Difference between socket bind names
Difference between socket bind names

Time:01-23

To create a new INET socket on a particular port, what is the difference between doing the following:

serversocket.bind((socket.gethostname(), 80))

And leaving the bind name empty:

serversocket.bind(('', 80))

CodePudding user response:

It only matters if your machine has more than one IP address. If you give a specific name, you will bind to whatever IP address that host resolves to. The empty string will bind you to all addresses.

  •  Tags:  
  • Related