Python Library TCP Socket
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

tcp_socket__tcp_server.py 485B

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('127.0.0.1', 17000)
  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