Answer the question
In order to leave comments, you need to log in
How to transfer a file of unknown size?
How will the receiving party understand that the end of the file has come?
How can you mark it?
Answer the question
In order to leave comments, you need to log in
You can mark with markers (boundaries), according to the EOF principle, but then you will have to read byte by byte until the cycle reaches the marker, it’s better otherwise - pass the file size in bytes in the header, and then the file itself, but then you need to take care of security, since there are bots on the Internet and their "visit" to the server is much more likely than you think, why "come" to a random IP and not a random port 80 at all remains a mystery, but bots have their own logic, which means you need to protect yourself from "left" packets that will have arbitrary instead of a header bytes and reading them will "clog" the RAM on the server and in any case the server will crash with an error.
You can look at implementations of HTTP, FTP.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question