Вопрос

Currently i'm having the problem, that if I send a buffer, it may be send only partially and return the count of bytes sent. Is there any way to set some option or sth. that prevents the bsd socket from sending partially?

Это было полезно?

Решение

Generally there is no way to do this with SOCK_STREAM socket types such as TCP. SOCK_DATAGRAM (for IP, this means UDP) and SOCK_SEQPACKET (for IP, there is no such thing) would do what you want, but with different limitations of their own.

In any case, the solution is that you need to do your own data buffering and framing. That is, you need to include in-band information in the stream you send that allows the recipient to reconstruct the "packet" boundaries you intended.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top