Advertisement
pantteri

Nux's recv function

Jan 4th, 2013
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1.     def recv(self):
  2.         # receive one character at time until "\n"
  3.         data = ""
  4.         while 1:
  5.             character = self.connection.recv(1)
  6.             if character:
  7.                 # only receive one line at time
  8.                 if character == '\n':
  9.                     break
  10.                 if character != '\r':
  11.                     data += character
  12.             else:
  13.                 print 'Connection closed'
  14.                 quit()
  15.        
  16.         self.display_and_log(' -> '+data)
  17.         self.line = data
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement