Ciur Eugen <(E-Mail Removed)> wrote in news:9eae2c03-951a-4013-9f49-
(E-Mail Removed):
> Below is an excerpt from a book:
>
> If the reason you can’t connect to the server is that the Unix socket
> file has been removed,
> you can get it back simply by restarting the server. (The server will
> re-create the
> socket file when it comes back up.) The trick here is that because the
> socket file is gone,
> you can’t use it to establish a connection for telling the server to
> stop.You must establish
> a TCP/IP connection instead.To do this, connect to the local server by
> using the
> --protocol=tcp option or by specifying a host value of 127.0.0.1
> rather than
>
> I have a question : TCP connection is not using a socket ? As far as I
> know whenever
> you create a tcp connection there is an socket created through which
> all communication
> is performed. Do I miss something ? Are there two different types of
> connection : socket and tcp ?
> Please help me to understood.
"Unix socket" isn't the same thing as "TCP socket".
A unix socket (also called 'unix domain socket' or 'AF_UNIX socket' or
'local socket') is a transport mechanism that only works on the local
machine. As with TCP sockets, there is a session-oriented version (like
TCP) and a datagram-style version of it (similar to UDP).
When you create the listening end of the unix socket, the kernel creates
a pseudo-file in the file system hierarchy based on a path name you
specify. The file's inode has a special bit set indicating that it's a
unix socket endpoint. In order to connect to the server, you create a
unix socket of your own and perform a connect(2) system call specifying
the path name of the pseudo-file. (See the unix(7) man page for more
detail.) If someone removes the pseudo-file from the directory (with
the rm(1) commmand for example), you will no longer be able to connect
to the server via the unix socket.
Some programs -- the X Windows server traditionally was one of these --
create a unix domain socket endpoint as well as a TCP socket endpoint.
The TCP socket endpoint doesn't have any representation in the file
system, so there is no danger of its endpoint being removed (other than
by killing the server program). I'm guessing that the book reference
you cited is referring to such a server that offers both types of
endpoints.
GH