def send_poetry(sock, poetry_file, num_bytes, delay):
 inputf = open(poetry_file)
 while True:
  bytes = inputf.read(num_bytes)
  if (not bytes):
   sock.close()
   inputf.close()
   return
  print ('Sending %d bytes' % len(bytes))
  try:
   sock.sendall(bytes)
  except socket.error:
   sock.close()
   inputf.close()
   return
  time.sleep(delay)

def send_poetry ( sock , poetry_file , num_bytes , delay ) : inputf = open ( poetry_file ) while True : bytes = inputf . read ( num_bytes ) if ( not bytes ) : sock . close ( ) inputf . close ( ) return print ( 'Sending %d bytes' % len ( bytes ) ) try : sock . sendall ( bytes ) except socket . error : sock . close ( ) inputf . close ( ) return time . sleep ( delay )
send some poetry slowly down the socket .