What I mean atomic is success or failed and do nothing.
I know socketpair(AF_LOCAL, SOCK_STREAM)
is not atomic, if multiple processes/threads call write(fd, buf, len)
, the return value of the write()
maybe > 0 && < len
and cause data out of order.
If multiple processes/threads write(buf, len)
to a sock_fd
which created by socketpair(AF_LOCAL, SOCK_SEQPACKET)
, is it atomic?
I check the Linux manual and found something about pipe()
which says if the len
is less than PIPE_BUF
, the write/writev
is atomic.
I found nothing about socketpair
. I wrote a test code and found it seems that the SOCK_SEQPACKET
is atomic, I write random length buffer to fd
and the return value is always -1
or len
.