Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

closed as off-topic by Chris S Feb 11 at 15:00

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions must demonstrate a minimal understanding of the problem being solved. Try including attempted solutions, why they didn't work, and the expected results. See How can I ask better questions on Server Fault? for further guidance." – Chris S
If this question can be reworded to fit the rules in the help center, please edit the question.

    
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 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. –  mikemaccana Feb 12 at 11:17
add comment

2 Answers 2

up vote 1 down vote accepted

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.

share|improve this answer
add comment

On Linux netstat -x reveals.

share|improve this answer
    
Is the rest of my question correct? –  George Bailey Jan 31 '11 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 '11 at 18:41
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.