Reputation: 846
Linux. Tcp socket.
When does a send()/write() command fail?
Does it return -1 only if the TCP send buffer in the kernel overflow?
Upvotes: 2
Views: 731
Reputation: 11515
To your specific point - if your write call was blocking, (as is the default), an overflow would just block you until there was buffer space available.
If the write call was non-blocking, and the buffers were full, you would receive an error.
Upvotes: 0
Reputation: 10502
From the OpenGroup definition for write():
Upon successful completion, write() [XSI] and pwrite() shall return the number of bytes actually written to the file associated with fildes. This number shall never be greater than nbyte. Otherwise, -1 shall be returned and errno set to indicate the error.
The same thing is done for send() - OpenGroup page for send()
You will find out more information by looking at the errno. See the OpenGroup page on errno for some more information.
Upvotes: 5