开发者

Sendto Failed C++ // POSIX.4

So - I'm running an application where two processes are talking over a UNIX domain socket. The vast majority of the messages being passed over the socket are processed correctly, but when the number of bytes in the message excedes a certain limit I start getting the error:

sendto failed: Message too long (POSIX.f)

I understand what its telling me. I can't change the message lengths and don't particularly want to spend time fragmenting messages - and its all in the same computer, so I shoudln't have to limit message leng开发者_如何学Cths over this domain socket.

Is there a way I can increase the amount of memory writable to the domain socket, or is there something I may have done wrong in the socket initialization/sendto/recvfrom calls that would have imposed a limit? The send/recv buffers I was using were pretty large (significantly larger than the messages causing the errors).


Are you using stream or datagram sockets? If they're stream sockets, you can just perform a second or third write to send the rest of the data. If they're datagram sockets, you're probably stuck (maybe you could switch to stream sockets?) but there may be a setsockopt option that would increase the limit. Still you may need to be prepared for the case where you can't increase the limit though. Essentially your problem is that the kernel would need to be responsible for holding onto a potentially large unit of data for an indefinite amount of time, which could easily lead to resource exhaustion and DoS, so the kernel (for very good reason) puts limits on the amount of data it will hold for you.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜