What is the correct way to set the buffer (ie., SO_RCVBUF, SO_SNDBUF) size of an accept()'d socket under Linux?
The obvious answer would be to call setsockopt() on the newly created socket, however the tcp man page states:
On individual connections, the socket buffer size must be set prior to the listen(2) or connect(2) calls in order to have it take effect. See socket(7) for more information.
That makes sense as the buffer is likely allocated upon creation and therefor I'll have to rely on the inheritance semantics of the listening socket by setting it's buffer size, except the man page (nor that of socket) makes any mention of inheritance and actually states:
On Linux, the new socket returned by accept() does not inherit file status flags such as O_NONBLOCK and O_ASYNC from the listening socket. This behavior differs from the canonical BSD sockets implementation. Portable programs should not rely on inheritance or noninheritance of file status flags and always explicitly set all required flags on the socket returned from accept()
It's not clear what "file status flags" refer to and whether or not it's inclusive of socket options and while having read a few related stackoverflow questions I'm none the wiser.