Working on a base for a simple chat client, and got the following error:
socket.error: [Errno 10049] The requested address is not valid in its context
The code is:
from socket import *
HOST = ''
PORT = 8000
s = socket(AF_INET, SOCK_STREAM)
s.connect((HOST, PORT))
i = True
while i is True:
msg = raw_input("Write A MSG: ")
s.send(msg)
print "Awaiting reply"
reply = s.recv(1024)
print "Recived: ", repr(reply)
s.close()
Thanks for helping.
The error is:
...
s.connect((HOST, PORT))
And it is because HOST = "". You may use HOST = "" when binding sockets. But when connecting, you should use HOST = "localhost" or HOST = "someaddr.com".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With