Answer the question
In order to leave comments, you need to log in
It is incorrect to transfer data from the server to the client, what is the reason?
I want to transfer file from server to client. but some of the bytes are not transmitted
on the server by the function that transmits
async def install(self, user=None):
if not user:
return
file = open(self.path_seving+"\\"+"starting.exe", "rb")
await self.main_loop.sock_sendfile(user, file, offset=0)
def install():
data = client.recv(1024)
file = open("starting.exe", "wb")
file.write(data)
while True:
data = client.recv(1024)
if not data: break
file.write(data)
Answer the question
In order to leave comments, you need to log in
well, for starters, you should close the file ... best of all - through the with statement.
def install():
with open("starting.exe", "wb") as file:
data = client.recv(1024)
while data:
file.write(data)
data = client.recv(1024)
user.shutdown(socket.SHUT_RDWR)
user.close()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question