You need to expand you protocol. Here are some ideas based on existing protocols:
| HTTP | The size of the body ("Content-Length") is transmitted before the body itself, so the receiver knows when to stop listening for the body and start listening for another request or response. Pro: Trivial to implement.
|
| FTP | A command connecion is maintained. Commands are exchanged to create new connections over which data is transfered. Pro: Handles errors easily.
|
| SLIP | Packets are terminated with a special character ("\0300") that is not allowed to exist anywhere else in the stream. An encoding mechanism is provided to transmit these special characters as data ("\0300" is encoded as "\0333\0334" and "\0333" is encoded as "\0333\0335"). Pro: Easy to implement.
|
Update: Added pros and cons.
In reply to Re: How to end socket file transfer without closing socket
by ikegami
in thread How to end socket file transfer without closing socket
by redss
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |