Fork me on GitHub
# from socket import *
# client=socket(AF_INET,SOCK_STREAM)
# client.connect(('127.2.2.2',6689))
# client.send('hello'.encode('utf-8'))
# client.send('world'.encode('utf-8'))
# client.close()
# from socket import *
# import time
# client=socket(AF_INET,SOCK_STREAM)
# client.connect(('127.2.2.2',6689))
# client.send('hello'.encode('utf-8'))
# time.sleep(5)
# client.send('world'.encode('utf-8'))
# client.close()

# from socket import *
# client=socket(AF_INET,SOCK_STREAM)
# client.connect(('127.2.2.2',6688))
# while True:
#     cmd=input('>>:').strip()
#     if not cmd:continue
#     client.send(cmd.encode('utf-8'))
#     recv_size=0
#     data=b''
#     while recv_size<total_size:
#         recv_data=client.recv(1024)
#         data+=recv_data
#         recv_size+=len(recv_data)
#     print(data.decode('gbk'))
# client.close()

# from socket import *
# import struct
# client=socket(AF_INET,SOCK_STREAM)
# client.connect(('127.2.2.2',6688))
# while True:
#     cmd=input('>>:').strip()
#     if not cmd:continue
#     client.send(cmd.encode('utf-8'))
#     headers=client.recv(4)
#     total_size=struct.unpack('i',headers)[0]
#     recv_size=0
#     data=b''
#     while recv_size<total_size:
#         recv_data=client.recv(1024)
#         data+=recv_data
#         recv_size+=len(recv_data)
#     print(data.decode('gbk'))
# client.close()
posted on 2020-01-02 20:24  OBOS  阅读(167)  评论(0编辑  收藏  举报