Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering if there is an easy way to find the maximum size that is supported by Linux sockets? (Is this configurable? If so where?)

For example, most of the socket examples found on the web send "Hello Socket" or some such other small string, however if I put the whole of War And Peace into the socket, when does it break?

As everything is a file, is it the maximum file size? How is it coordinated when sockets connect different file systems?

I'm most interested in stream sockets.

share|improve this question
Re War & Piece: be mindful of the EFELL_ASLEEP error code from read. – Mat May 6 '12 at 21:42
up vote 1 down vote accepted

net.core.rmem_max and net.core.wmem_max are your thing. You can examine their values with

# sysctl net.core.rmem_max

and set them with

# sysctl -w net.core.rmem_max=8388608

These are the socket buffer sizes, when receiving and sending, respectively. They have default values, too, - rmem_default and wmem_default.

share|improve this answer
Thanks, this is what i was looking for. – NWS May 7 '12 at 16:04

You didn't say what type of sockets.

Stream sockets

You can send (by definition) an unlimited amount of data. If it cannot all be buffered or sent at once or if the receiver cannot receive it all at once, the send will either block (for blocking sockets) or return a partial count of bytes written or EAGAIN (for nonblocking sockets).

Datagram sockets

It depends on the protocol. UDPv4 supports only 65536 bytes per datagram. UDPv6 supports much more. UNIX domain sockets probably support still more: you are probably just limited by memory in this case.

share|improve this answer
Stream Sockets Actually - Although i didnt know there would be a difference. – NWS May 6 '12 at 20:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.