Hello,
I can't seem to get my sockets code to work right. Here is what I
have inside my RequestHandler handle() function:
total_data=[]
data = True
logger_server.d ebug(self.__cla ss__.__name__ + ' set data =
True')
while data:
logger_server.d ebug(self.__cla ss__.__name__ + ' receive
first readline() of data')
data = self.rfile.read line().strip()
logger_server.d ebug(self.__cla ss__.__name__ + ' first
readline() of data = %s' % data)
total_data.appe nd(data)
receivedCommand = '\n'.join(total _data)
And this is what I have inside my client code
sock=socket.soc ket(socket.AF_I NET,socket.SOCK _STREAM)
sock.connect((' localhost',5001 ))
sock.sendall('H ello, world\r\n')
data = sock.recv(1024)
sock.close()
print 'Received', repr(data)
There's a little more to it, but this is enough for me to ask my
question. The problem is that I can't get the server loop (while
data:) to stop without closing the connection, but I want to receive
something back from the server before closing the sockets connection.
My logs show that the server never leaves the loop.
Thanks in advance.
I can't seem to get my sockets code to work right. Here is what I
have inside my RequestHandler handle() function:
total_data=[]
data = True
logger_server.d ebug(self.__cla ss__.__name__ + ' set data =
True')
while data:
logger_server.d ebug(self.__cla ss__.__name__ + ' receive
first readline() of data')
data = self.rfile.read line().strip()
logger_server.d ebug(self.__cla ss__.__name__ + ' first
readline() of data = %s' % data)
total_data.appe nd(data)
receivedCommand = '\n'.join(total _data)
And this is what I have inside my client code
sock=socket.soc ket(socket.AF_I NET,socket.SOCK _STREAM)
sock.connect((' localhost',5001 ))
sock.sendall('H ello, world\r\n')
data = sock.recv(1024)
sock.close()
print 'Received', repr(data)
There's a little more to it, but this is enough for me to ask my
question. The problem is that I can't get the server loop (while
data:) to stop without closing the connection, but I want to receive
something back from the server before closing the sockets connection.
My logs show that the server never leaves the loop.
Thanks in advance.
Comment