Network types for Unix domain sockets

1,936 views
Skip to first unread message

Archos

unread,
Jul 26, 2012, 9:07:24 AM7/26/12
to golan...@googlegroups.com
Which is the difference between "unix", "unixgram" and "unixpacket"? In Unix domain sockets.

Kyle Lemons

unread,
Jul 26, 2012, 2:25:14 PM7/26/12
to Archos, golan...@googlegroups.com
I believe "unix" (and "unixpacket", which seems to be an alias for it) are stream-oriented and "unixgram" is datagram oriented.

Archos

unread,
Jul 26, 2012, 7:29:10 PM7/26/12
to golan...@googlegroups.com
Reading here[1], it looks that "unix" and "unixpacket" are different

[1]: http://golang.org/src/pkg/net/unixsock_posix.go#L17

Peter S

unread,
Jul 26, 2012, 8:42:20 PM7/26/12
to Archos, golan...@googlegroups.com
From "man 2 SOCKET":

       SOCK_STREAM     Provides sequenced, reliable, two-way, connection-based
                       byte  streams.  An out-of-band data transmission mecha‐
                       nism may be supported.

       SOCK_DGRAM      Supports datagrams (connectionless, unreliable messages
                       of a fixed maximum length).

       SOCK_SEQPACKET  Provides  a  sequenced,  reliable,  two-way connection-
                       based data transmission path  for  datagrams  of  fixed
                       maximum  length;  a  consumer  is  required  to read an
                       entire packet with each input system call.

Based on the source code you linked, it appears that "unix" uses SOCK_STREAM, "unixgram" uses SOCK_DGRAM, and "unixpacket" uses SOCK_SEQPACKET.

Hope that helps,

Peter

Archos

unread,
Jul 29, 2012, 3:20:48 AM7/29/12
to golan...@googlegroups.com
`man 7 unix` gives little more information:

SOCK_STREAM,  for  a  stream-oriented  socket

SOCK_DGRAM, for  a  datagram-oriented  socket  that  preserves  message boundaries (as on most UNIX implementations, UNIX domain datagram sockets are always reliable and don't reorder datagrams)

SOCK_SEQPACKET (since  Linux 2.6.4), for a connection-oriented socket that preserves message boundaries and delivers messages in the order  that  they  were sent.
Reply all
Reply to author
Forward
0 new messages