1 # 编辑者:闫龙
 2 import socket,json,struct
 3 class MySocket:
 4     with open("FtpServiceConfig","r",encoding="utf8") as f:
 5         Config = json.loads(f.read())
 6         AFType= eval("socket."+Config["AFType"])
 7         KIND=eval("socket."+Config["KIND"])
 8         IPaddress= Config["IPaddress"]
 9         Port=Config["Port"]
10         MaxLinks=Config["MaxLinks"]
11     def __init__(self):
12         self.SockObj = socket.socket(self.AFType,self.KIND)
13         self.SockObj.bind((self.IPaddress,self.Port))
14         self.SockObj.listen(self.MaxLinks)
15     def Starting(self):
16         self.Clients,self.IpInfo=self.SockObj.accept()
17     def GetHeadLen(self):
18         return struct.unpack("i",self.Clients.recv(4))[0]
19     def GetHead(self,Len:int):
20         return json.loads(self.Clients.recv(Len).decode("utf8"))
21     def GetDatas(self,Len:int):
22         return self.Clients.recv(Len)
23     def SendDatas(self,SendWhat):
24         self.Clients.send(SendWhat.encode("utf8"))
25     def ClientBye(self):
26         self.Clients.close()
27     def ByeBye(self):
28         self.SockObj.close()
FTP服务器类

相关文章:

  • 2022-12-23
  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-12-30
  • 2021-12-10
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-06
  • 2022-01-18
  • 2022-02-20
  • 2021-05-16
  • 2022-02-15
相关资源
相似解决方案