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?

700 Software
  • 2,323

2 Answers2

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.

poige
  • 9,730
  • 3
  • 28
  • 53