I've been trying to wrap my head around how sockets work, and I've been trying to pick apart some sample code I found at this page for a very simple client socket program. Since this is basic sample code, I assumed it had no errors, but when I try to compile it, I get the following error message.
File "client.py", line 4, in
File "", line 1, in connect
socket.error: [Errno 111] Connection refused
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
data = client_socket.recv(512)
if ( data == 'q' or data == 'Q'):
print "RECIEVED:" , data
data = raw_input ( "SEND( TYPE q or Q to Quit):" )
if (data <> 'Q' and data <> 'q'):
It's trying to connect to the computer it's running on on port 5000, but the connection is being refused. Are you sure you have a server running?
If not, you can use
netcat for testing:
nc -l -k -p 5000
Some implementations may require you to omit the