The problem
I am trying to use the SocketServer that ships with Python but I have some issues in the handshake phase. The handshake works fine as long as I use localhost or 127.0.0.1. However when I put the IP of my eth0 card it just won't handshake. I test the official example code found here:
import SocketServer
class MyTCPHandler(SocketServer.BaseRequestHandler):
def handle(self):
self.data = self.request.recv(1024).strip()
print "{} wrote:".format(self.client_address[0])
print self.data
self.request.sendall(self.data.upper())
if __name__ == "__main__":
HOST, PORT = "localhost", 9999
server = SocketServer.TCPServer((HOST, PORT), MyTCPHandler)
server.serve_forever()
Terminal snippet:
manos@box:~$ netcat 10.2.203.26 9999
manos@box:~$
manos@box:~$ netcat localhost 9999
test
As you see in the snippet, trying to connect to 10.2.293.26
which is the IP of my network card doesn't work. As soon as I try to connect to localhost
, it works fine!
On Wireshark I get a [RST, ACK]
after the first SYN being sent from the client to the server (in the initial handshake phase).
Works fine with telnet
My first guess was that this was a router resetting the connection. However that is not the case since I can telnet
fine:
Terminal 1:
manos@box:~/tmp/test$ netcat -l 9999
(waiting)
test
Terminal 2:
manos@box:~$ netcat 10.2.203.26 9999
test