I'm trying to get some basic networking going in python. Here's the snippet of the program that does the actual communication:
Client Side
# open socket and connect to port
sock = socket(AF_INET, SOCK_STREAM)
sock.connect((regHost, regPort))
# prepare flos for data
outFlo = sock.makefile(mode='w')
inFlo = sock.makefile(mode='r')
outFlo.write(queryString)
outFlo.flush()
print "finished writing"
tmp = inFlo.readline()
print tmp
outFlo.close()
inFlo.close()
sock.close()
Server Side
print 'Spawned thread'
inFlo = self.sock.makefile(mode='r')
outFlo = self.sock.makefile(mode='w')
outFlo.write('test writing\n')
outFlo.flush()
inFlo.close()
outFlo.close()
self.sock.close()
print 'Closed socket'
print 'Exiting thread'
The program seems to be hanging on the call to inFlo.readline() in the client side. Any help would be much appreciated.
asked Mar 14, 2011 at 2:04
themaestro
14.4k21 gold badges59 silver badges76 bronze badges
1 Answer 1
The error was that I forgot to add a \n at the end of one of my strings. Due to that, the program was hanging on the call to inFlo.readline().
answered Mar 14, 2011 at 2:56
themaestro
14.4k21 gold badges59 silver badges76 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py