L
L
luaPower2021-06-20 14:36:10
linux
luaPower, 2021-06-20 14:36:10

How can I find out the maximum size of data that can be written to a socket?

Hello.

Let's say the socket is in non-blocking mode.
How to find out the number of bytes in the socket buffer available for writing new data?
So that the send call does not return EAGAIN or EWOULDBLOCK errors.

Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
4
4X_Pro, 2021-06-20
@luaPower

In Linux directly - in any way. You can get the buffer size with getsockopt and get the amount of unsent data with ioctl(socket,SIOCOUTQ) and then subtract one from the other.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question