Python Library TCP Socket
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

tcp_socket__stp_server.py 489B

123456789101112131415161718192021222324
  1. import sys
  2. sys.path.append('../..')
  3. import report
  4. import tcp_socket
  5. import time
  6. def mirror_callback(tcp):
  7. tcp.send(tcp.receive())
  8. report.stdoutLoggingConfigure(log_name_lvl=[('root', 'DEBUG'), ])
  9. s = tcp_socket.tcp_server_stp('127.0.0.1', 17017)
  10. s.register_callback(mirror_callback)
  11. i = 0
  12. while not s.is_connected() and i <= 10:
  13. i += 1
  14. time.sleep(.1) # wait for a connection
  15. i = 0
  16. while s.is_connected() and i <= 10:
  17. i += 1
  18. time.sleep(.1) # wait for disconnect