Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!dcl-cs!aber-cs!athene!pcg From: pcg@cs.aber.ac.uk (Piercarlo Grandi) Newsgroups: comp.protocols.tcp-ip Subject: Re: What is a UNIX Domain Socket? Message-ID: Date: 9 Oct 90 20:28:02 GMT References: <82@unigold.UUCP> <1990Sep27.180632.25841@dg-rtp.dg.com> Sender: pcg@aber-cs.UUCP Organization: Coleg Prifysgol Cymru Lines: 68 Nntp-Posting-Host: odin In-reply-to: harvey@dg-rtp.dg.com's message of 27 Sep 90 18:06:32 GMT On 27 Sep 90 18:06:32 GMT, harvey@dg-rtp.dg.com (Michael Harvey) said: harvey> In article <82@unigold.UUCP>, lance@unigold.UUCP (Lance harvey> Ellinghouse) writes: lance> Ok, I know this is a dumb question.. What exactly is a Unix lance> Domain Socket? What makes it different from a INET Socket? harvey> A socket is simply a communication endpoint. Sockets support harvey> two communications domains: the UNIX domain for harvey> process-to-process communication on the same host, and the harvey> Internet domain for process-to-process communication between harvey> hosts that communicate with one another using the DARPA standard harvey> communication protocols, such as IP, TCP, and UDP. harvey> In the UNIX domain, socket names are UNIX pathnames; harvey> for example, a socket may be named /tmp/foo. harvey> Naming sockets in the Internet domain involve concatenating harvey> the Internet address with a port number. harvey> I think that covers the basics. Comments? I think I can do better :-). Under Unix all out-of-address space communication (except for ptrace(2) and signals) is via file descriptors; file descriptors have a common interface, based on read/write readv/writev, and ioctl(), etc..., and a type. One of the types of a file descriptor is socket; when a file descriptor is a socket, it is attached using a full duplex channel to another socket file descriptor somewhere. Socket file descriptors have a number of properties that normal file descriptors do not have; among these are the type of communication (stream, message, etc...), an identifier, two modes of connecting a socket to another for transmitting data, and whether there is the possibility to transmit file descriptors over the channel. Socket file descriptors are supported by a a set of protocol implementations called a 'domain'; only sockets in the same domain may be connected. The UNIX domain is a domain where there is only one socket type, only one protocol, the pipe protocol, where the only socket type allowed is stream, where socket identifiers are pathnames in the UNIX filesystem, and where filedescriptors may be passed thru the communication channel between two sockets. By contrast the INET domain supports three socket types (stream, datagram and raw), a number of protocols, socket identifiers are internet 32 bit numbers, and filedescriptors may not be passed thru the channel between two sockets. Many other domains exist. In the original 4.2BSD design it was to be possible to have user processes implement domains, by putting the protocol code in the user process, and having all communications between two sockets in that user domain be interepted by the user process implementing that domain. This is still possible by using the UNIX domain, even if in a contrived way (in particular it is not possible to support other than stream sockets), by having users for that domain connect in the UNIX domain to the user implemented domain server, that would return a socket in that domain (actually a socket to itself, usually, in the UNIX domain). -- Piercarlo "Peter" Grandi | ARPA: pcg%uk.ac.aber.cs@nsfnet-relay.ac.uk Dept of CS, UCW Aberystwyth | UUCP: ...!mcsun!ukc!aber-cs!pcg Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@cs.aber.ac.uk