Yes, this is normal. If you write to a socket (non-blocking or not) where the other end has closed the connection, you will get a SIGPIPE
or (if you are blocking the SIGPIPE
signal) an error return (-1
) with errno
set to EPIPE
.
From the man page for write
:
EPIPE
:fd
is connected to a pipe or socket whose reading end is closed. When this happens the writing process will also receive aSIGPIPE
signal. (Thus, the write return value is seen only if the program catches, blocks or ignores this signal.)
The POSIX standard is here: http://pubs.opengroup.org/onlinepubs/009695399/functions/write.html and says:
[EPIPE]
An attempt is made to write to a pipe or FIFO that is not open for reading by any process, or that only has one end open. ASIGPIPE
signal shall also be sent to the thread.