Please see the example output at:
connection refused
The question I have is why the first call to s.connect() throws “Connection Refused”, but the second call throws “Invalid Argument”. It’s like the first call put the socket object s into some kind of error state. Is there a way to reset it?
Thanks
You are calling this:
gethostname()involves more than just connecting to server. It initializes the variables for the socket.Next time you call
connect,salready have a value, but invalid. So, you getInvalid argument.Note:
s.connect()actually callsconnect()withsas the first argument, as connect is defines asdef connect(self, ...).