0

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

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.