Skip to content
Advertisement

Cannot connect to socket on ” ip address. Python

He, I have a server python script that listens on ip address '' and port 1337 and now I am trying to connect on the client side to that socket. But for some reason I cannot do that. If i will change the binding address to "127.0.0.1" it will work just fine, but I have been told to use this ip address ''.

Can someone please explain me why this is heppening and what is this ip address mean?.

This is my server:

JavaScript

This is my client:

JavaScript

And this is the weeor that I am getting:

JavaScript

Advertisement

Answer

The IP address '' (i.e., wildcard) in the server code represents the any address. This means that the server will listen on all available network interfaces.

'' is equivalent to 0.0.0.0 and is used only in the server, not a client. For a client, it requires knowing the actual IP address of the server in order to connect to it.

Consequently, using the IP address 127.0.0.1 in the client code is already correct.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement