"""
""
server.py
"""
Service side
"""
Import socket
Import OS
S=socket.socket ()
S.bind ((' 127.0.0.1 ', 8888,))
S.listen (5)
While True:
C,addr=s.accept ()
C.sendall (Bytes ("Upload ftp", encoding= "Utf-8"));
File_size=str (C.recv (1024x768), encoding= "Utf-8");
Print (file_size)
Total_size=int (file_size);
Hots=0
Print (file_size);
C.sendall (Bytes ("Wash", encoding= "Utf-8"));
F=open (' d:/jpg/2.jpg ', ' WB ')
While True:
If hots==total_size:
Break
DATA=C.RECV (1024)
F.write (data)
Hots+=len (data);
F.close ()
Client
c.py
"""
FTP Client
"""
Import Socket
Import Json,os
S=socket.socket ()
S.connect (("127.0.0.1", 8888,))
REST_BYTES=S.RECV (1024)
Res_str=str (rest_bytes,encoding= "UTF-8");
Print (RES_STR)
File_size=os.stat (' d:/jpg/1.jpg '). st_size
S.sendall (bytes (str (file_size), encoding= "Utf-8"));
S.RECV (1024)
#发送文件
With open (' d:/jpg/1.jpg ', ' RB ') as F:
For line in F:
S.sendall (line);
F.close ();
c.py
Socket upload File