我试图将文件从服务器发送到客户端,但出现错误。请告诉我我哪里做错了。在
这是我的服务器代码:
if msg in data.keys():
print("Requested file exists", msg)
f=open(msg,"rb")
datam= f.read(1024)
while (datam):
if(s.send(datam)):
print "sending data"
datam = f.read(1024)
s.close()
f.close
else:
print("File Not found",msg)
print("File Not found",data.keys())
c.close() # Close the connection
其中msg包含文件所在的路径地址 c=客户端套接字s=服务器套接字 我想读取该文件并将其发送到客户端,但我得到了这个错误
^{pr2}$在客户端,我编写了这个代码来接收该文件
s.listen(15)
f = open('\home\beenish\pictures\lol.txt', 'wb')
data = s.recv(1024)
while(data):
f.write(data)
data=s.recv(1024)
f.close()
s.close # Close the socket when done
其中s是客户端套接字
我得到了这个错误
Traceback (most recent call last):
File "client.py", line 26, in <module>
s.listen(15)
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 22] Invalid argument
在客户端,这一行有一个错误:
并且Python docs表示参数具有依赖于系统的最大值,通常为5。所以试着找出你的系统的最大值,只使用一个较低的值,看看会发生什么。在
服务器端错误可能是客户端故障的副作用。在
这是在调用^{} 之前调用^{} 时遇到的错误。请记住,服务器总是必须按照特定的顺序}的顺序。在
socket()
、bind()
、listen()
和{相关问题 更多 >
编程相关推荐