Operating System - HP-UX
1822430 Members
3054 Online
109642 Solutions
New Discussion юеВ

what is Unix Active domain socket

 
Goh Kian Soon
New Member

what is Unix Active domain socket

When the netstat -a is issue, a similar sentence as above appear, what does this mean and what does each sentence below it denote?
2 REPLIES 2
Dirk Wiedemann
Respected Contributor

Re: what is Unix Active domain socket

Hello Goh Kian,

in UNIX as a real network oriented operating system various programms use network mechanism for interprocess communication. Therefor e.g. active daemons open local ports and listen to them, waiting for other processes to communicate together. This is the standard mechanism for UNIX interprocess communication called UNIX domain socket.
The netstat -a command shows you both active ports: first the active internet connections (real network communication) and after that the active UNIX domain sockets (only local on your system).

Hope this helps to undestand.
regards
Dirk
U.SivaKumar_2
Honored Contributor

Re: what is Unix Active domain socket

Hi,
Ref:
Sockets are used for communication, particularly over a network. Sockets were originally developed by the BSD branch of Unix systems, but they are generally portable to other Unix-like systems: Linux and System V variants support sockets as well, and socket support is required by the Open Group's Single Unix Specification [Open Group 1997]. System V systems traditionally used a different (incompatible) network communication interface, but it's worth noting that systems like Solaris include support for sockets. Socket(2) creates an endpoint for communication and returns a descriptor, in a manner similar to open(2) for files. The parameters for socket specify the protocol family and type, such as the Internet domain (TCP/IP version 4), Novell's IPX, or the ``Unix domain''. A server then typically calls bind(2), listen(2), and accept(2) or select(2). A client typically calls bind(2) (though that may be omitted) and connect(2). See these routine's respective man pages for more information. It can be difficult to understand how to use sockets from their man pages; you might want to consult other papers such as Hall "Beej" [1999] to learn how these calls are used together.

The ``Unix domain sockets'' don't actually represent a network protocol; they can only connect to sockets on the same machine. (at the time of this writing for the standard Linux kernel). When used as a stream, they are fairly similar to named pipes, but with significant advantages. In particular, Unix domain socket is connection-oriented; each new connection to the socket results in a new communication channel, a very different situation than with named pipes. Because of this property, Unix domain sockets are often used instead of named pipes to implement IPC for many important services. Just like you can have unnamed pipes, you can have unnamed Unix domain sockets using socketpair(2); unnamed Unix domain sockets are useful for IPC in a way similar to unnamed pipes.

There are several interesting security implications of Unix domain sockets. First, although Unix domain sockets can appear in the filesystem and can have stat(2) applied to them, you can't use open(2) to open them (you have to use the socket(2) and friends interface). Second, Unix domain sockets can be used to pass file descriptors between processes (not just the file's contents). This odd capability, not available in any other IPC mechanism, has been used to hack all sorts of schemes (the descriptors can basically be used as a limited version of the ``capability'' in the computer science sense of the term). File descriptors are sent using sendmsg(2), where the msg (message)'s field msg_control points to an array of control message headers (field msg_controllen must specify the number of bytes contained in the array). Each control message is a struct cmsghdr followed by data, and for this purpose you want the cmsg_type set to SCM_RIGHTS. A file descriptor is retrieved through recvmsg(2) and then tracked down in the analogous way. Frankly, this feature is quite baroque, but it's worth knowing about.

regards,
U.SivaKumar

Innovations are made when conventions are broken