Client初见——python
from socket import *
ip_port = ('127.0.0.1',8080)
back_log = 5
buffer_size = 1024
tcp_client = socket(AF_INET,SOCK_STREAM)
tcp_client.connect(ip_port)
while True:
msg = input('>>>').strip()
tcp_client.send(msg.encode('utf-8'))
print('客户端已经发送消息')
data = tcp_client.recv(buffer_size)
print('收到服务端的消息',data.decode('utf-8'))
tcp_client.close
Win a contest, win a challenge
posted on 2018-03-09 06:29 pandaboy1123 阅读(130) 评论(0) 编辑 收藏 举报