tcp-client.py 460 B

1234567891011121314151617181920
  1. import socket
  2. import json
  3. ADDRESS =('192.168.50.162',1881)
  4. client_type= 'test'
  5. def input_client_type():
  6. return input("輸入:")
  7. client_type = input_client_type()
  8. client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  9. client.connect(ADDRESS)
  10. ##print(client.recv(1024).decode(encoding='utf8'))
  11. ##send_data(client,'CONNECT')
  12. while True:
  13. a=input("輸入:")
  14. a=a+'\n'
  15. print('send:'+a)
  16. client.sendall(a.encode('utf8'))