发送端:
from socket import * s=socket() s.connect(('127.0.0.1',8888)) f=open('mm.jpg','rb') while True: data=f.read(1024) if not data: break s.send(data) f.close() s.close()
接收端:
from socket import * s=socket() s.bind(('127.0.0.1',8888)) s.listen(5) c,addr=s.accept() print('connnect from ',addr) f=open('ll.jpg','wb') while True: data=c.recv(1024) if not data: break f.write(data) f.close() c.close() s.close()