标签:image inpu img recv ddr encode enc png 格式
from socket import * 不用每次调用加socket
tcp_server=socket(AF_INET,SOCK_STREAM)
收发消息是字节格式
import socket phone=socket.socket(socket.AF_INET,socket.SOCK_STREAM) phone.bind((‘192.168.1.6‘,8002)) phone.listen(5) print(‘------>‘) conn,addr=phone.accept() while True: msg=conn.recv(1024) print(type(msg)) print(‘来自客户端的消息‘,msg.decode(‘utf-8‘)) conn.send(msg.upper()) conn.close() phone.close()
import socket phone=socket.socket(socket.AF_INET,socket.SOCK_STREAM) phone.connect((‘192.168.1.6‘,8002)) while True: msg=input(‘>>:‘).strip() if not msg: continue phone.send(msg.encode(‘utf-8‘)) print(123) data=phone.recv(1024) print(‘来自服务端的消息‘,data.decode(‘utf-8‘)) phone.close()
标签:image inpu img recv ddr encode enc png 格式
原文地址:https://www.cnblogs.com/jintian/p/10970753.html