4

I think the differences are

  • You connect to the server by providing the file path instead of the destination IP/port
  • There is no such thing as a source port.. Also, the source IP would only be localhost.

I think that each open UNIX Domain socket still has the same two streams,, input stream and output stream.

Is this all correct?

Also, is the file required to be known when connecting to a UNIX Domain socket? Can a non root user find UNIX domain sockets and connect to them?

2
  • Pickup a copy of UNIX Network Programming - Volume II It explains all this stuff much better than a limited answer here would.
    – Chris S
    Feb 11, 2014 at 15:01
  • 1
    I think the question should be taken off hold - 'minimal understanding' is clearly demonstrated, the user has shown they have some knowledge of domain sockets. While they haven't read man socket many people aren't aware the manual covers more than just commands. Feb 12, 2014 at 11:17

2 Answers 2

4

Yes, UNIX domain sockets use the file system as the address name space, .i.e. the file path instead of URL/IP and port. The man page for socket says

Socket creates an Internet domain TCP or a UNIX domain stream socket and connects it to stdin and stdout. The host argument can be an Internet number in dot-notation (like ``130.149.28.10'') or a domain name. In this case it must be possible to resolve the name to a valid Internet address with gethostbyname. The port argument can be a port number or a service name which can be mapped to a port number by getservbyname. If an UNIX domain socket is wanted to be created instead of an Internet socket, specify the path instead of an internet (canonical domain named or dot-notated) host. The hostname is treated as a pathname if contains at least a single slash. I.e. if one wants to create or connect to a socket in the current directory, use ./filename to specify the connection point.

Unix domain sockets are faster than IP Sockets for local interprocess communication, see here and here or this related question.

-1

On Linux netstat -x reveals.

2
  • Is the rest of my question correct? Jan 31, 2011 at 18:31
  • 2
    man 7 unix: «… In the Linux implementation, sockets which are visible in the file system honor the permissions of the directory they are in. Their owner, group and their permissions can be changed. Creation of a new socket will fail if the process does not have write and search (execute) permission on the directory the socket is created in. Connecting to the socket object requires read/write permission. This behavior differs from many BSD-derived systems which ignore permissions for UNIX domain sockets. Portable programs should not rely on this feature for security. …»
    – poige
    Jan 31, 2011 at 18:41

Not the answer you're looking for? Browse other questions tagged .