阿里云服务器年费多少,seo企业站收录,小程序代码怎么获取,ip地址直接访问网站这是一个使用Python中的TCP套接字的文件传输应用程序。文件传输协议将包含一个名为ftps.py文件一个客户打电话来ftpc.py文件. 在文件传输应用程序将使用一个简单的协议。前4个字节(按网络字节顺序)将包含后续文件中的字节数。接下来的20个字节将包含文件的名称(假设名称可以容纳…这是一个使用Python中的TCP套接字的文件传输应用程序。文件传输协议将包含一个名为ftps.py文件一个客户打电话来ftpc.py文件. 在文件传输应用程序将使用一个简单的协议。前4个字节(按网络字节顺序)将包含后续文件中的字节数。接下来的20个字节将包含文件的名称(假设名称可以容纳20个字节)。接下来的TCP流中的其余字节将包含文件中的数据。在我在不同的计算机上运行客户机程序和服务器程序但有两个错误1) 当我编码文件名并将其发送到套接字时当服务器端接收并解码时文件名是不正确的2)服务器端似乎陷入了while循环我不知道为什么客户import socketimport sysimport osfilenamesys.argv[2]print filenameif len(sys.argv) 1 :print(Trying to connect...)s socket.socket()ip_add(sys.argv[1])print(ip_add)s.connect((ip_add, 4000))print(Connected. Wating for command.)while True:cmd s.recv(24)if cmd getsize:print(getsize command received.)statinfoos.stat(filename)byte_sizestatinfo.st_sizesize_strstr(byte_size)s.sendall(size_str)if cmd getfilename:print(getfilename command received.)formatted_name filename.rjust(20)fname formatted_name.lstrip()print(fname)encoded_filenamefname.encode(utf-8)s.sendall(encoded_filename)if cmd getfile:print(getfile command received. Going to send file.)file_input open(sys.argv[2], rb)while True:buff file_input.read(512)if len(buff) 0:breaks.sendall(buff)print(File transmission done.)if cmd end:print(end command received. Teminate.)breakfile_input.close()f.close()服务器^{pr2}$以下是服务器程序的终端输出% python ftps.pyWaiting for clinet to connect...Connected. Going to receive file.1797Filename: 55客户端输出% python ftpc.py 164.107.113.20 2.jpg2.jpgTrying to connect...164.107.113.20Connected. Wating for command.getsize command received.getfilename command received.2.jpggetfile command received. Going to send file.File transmission done.文件名55应该是文件名2.jpg程序在这一点上陷入了一个循环。。有人知道为什么会这样吗在