i have seen in some examples that when they are explaining the sockets they write a sck.bind(('',PORT)) for server and a sck.connect(('',PORT)) for the client part but when i try to use this code it doesnt work but when i change the client part to sck.connect(('localhost',PORT)) it works fine.
so where is the problem?
and of course i dont really know what bind method does,i know that it binds the host to port but i dont know what this exactly mean ,if you are programming a server-client program when you have a server on the web what should you write in bind method.

8 Years
Discussion Span
Last Post by tzushky

Normally you give an IP and a Port. When you tuple them together, that is an ADDRESS for the bind() method and also for the rest of the methods like connect that you gave in your post.

That is valid for C too and I am sure for other programming languages. It is to give a very certain identity for the socket

bind( address)
Bind the socket to address.

Normally the empty string does not define an IP, some languages probably interpret it as localhost, but others may not....that is probably why it doesn't work, but localhost does (IP= understood by compiler/interpreter)

....This tutorial is very good:

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.