I am trying to send and receive file over TCP with Python. But recv() method get only 4KB of files, rest is discarded. How can ı get all bytes in file?
Asked
Active
Viewed 57 times
-1
-
The rest is not discarded. You have to loop. – user207421 May 09 '20 at 23:31
-
1Does this answer your question? [Python Socket Receive Large Amount of Data](https://stackoverflow.com/questions/17667903/python-socket-receive-large-amount-of-data) – metatoaster May 09 '20 at 23:35
1 Answers
1
recv is a low-level interface. It will read "bufsize" (defaults to 4k) bytes at a time. You need to keep calling it until it returns zero bytes back to you to get all the data.
See here for more: https://docs.python.org/3/howto/sockets.html#using-a-socket

user2199860
- 788
- 4
- 14