In the simplest terms, a socket is a pseudo-file that represents a network connection. Once a socket has been created (using the proper primitives, and the proper parameters to identify the other host), writes to the socket are turned into network packets that get sent out, and data received from the network can be read from the socket.
In one regard, ...
A good option might be lsof. As man lsof states it is handy for obtaining information about open files such as Internet sockets or Unix Domain sockets.
At first, get an overview about /proc/$PID/fd/ and the listed socket numbers.
For example, socket: might interest you.
Then use lsof -i -a -p $PID to print a list of all ...
Note: I now maintain a lsof wrapper that combines both approaches described here and also adds information for peers of loopback TCP connections at https://github.com/stephane-chazelas/misc-scripts/blob/master/lsofc
Linux-3.3 and above.
On Linux, since kernel version 3.3 (and provided the UNIX_DIAG feature is built in the kernel), the peer of a given unix ...
UNIX domain sockets should offer better performance than TCP sockets over loopback interface (less copying of data, fewer context switches).
Beware though that sockets are only reachable from programs that are running on the same server (there's no network support, obviously) and that the programs need to have the necessary permissions to access the socket ...
A socket is a file. But not all files have names. Here are a few examples of files that don't have names:
Any file that used to have a name, and is now deleted, but is still opened by a program.
An unnamed pipe, such as one created by the | shell operator.
Most sockets: any Internet socket, or a Unix socket which is not in the filesystem namespace (it can ...
UNIX domain sockets and FIFO may share some part of their implementation but they are conceptually very different. FIFO functions at a very low level. One process writes bytes into the pipe and another one reads from it. A UNIX domain socket has the same behaviour as a TCP/IP socket.
A socket is bidirectional and can be used by a lot of processes ...
The limit on "open files" is not really just for files. It's a limit on the number of kernel handles a single process can use at one time. Historically, the only thing that programs would typically open a lot of were files, so this became known as a limit on the number of open files. There is a limit to help prevent processes from say, opening a lot of files ...
The @ probably indicates a socket held in an abstract namespace which doesn't belong to a file in the filesystem.
Quoting from The Linux Programming Interface by Michael Kerrisk:
57.6 The Linux Abstract Socket Namespace
The so-called abstract namespace is a Linux-specific feature that
allows us to bind a UNIX domain socket to a name without that ...
It's part of the TCP (or UDP, etc.) header, in the packet. So the server finds out because the client tells it. This is similar to how it finds out the client's IP address (which is part of the IP header).
E.g., every TCP packet includes an IP header (with source IP, destination IP, and protocol [TCP], at least). Then there is a TCP header (with source and ...
When you are using TCP, you are also using the whole network stack. Even if you are on the same machine, this implies that packets are encapsulated and decapsulated to use the network stack and the related protocols.
If you use unix domain sockets, you will not be forced to go through all the network protocols that are required otherwise. The sockets are ...
Using nc (netcat).
$ nc -l localhost 3000
$ nc localhost 3000
Both server and client will read and write to standard output/input.
This will work when both server and client is on the same machine. Otherwise change localhost to the external name of the server.
Slightly more interesting, a "server" that gives you the time of day if you ...
The reason why TCP/IP sockets use file descriptors is that, when the sockets interface was first designed and implemented (in BSD Unix, in 1983), its designers felt that a network connection was analogous to a file - you can read, write, and close both, and that it would fit well with the Unix idea of "everything is a file".
Other TCP/IP network stack ...
netcat-openbsd supports connecting to UNIX-domain sockets. Using this you can connect to either a UNIX-domain stream socket or a UNIX-domain datagram socket, and therefore you have to tell the socket's type to netcat.
for example, /dev/log file in Linux is a UNIX-domain datagram socket socket, thus nc -U /dev/log won't work. Instead use nc -uU /dev/log. ...
To ensure the kernel won't give out 49000 and 49001 to clients as you wish to use them for your servers on linux.
sysctl -w net.ipv4.ip_local_reserved_ports = 49000, 49001
drop it in /etc/sysctl.conf, and then run sysctl -p.
Note that this is untested.
Documentation / networking / ip-sysctl.txt
sockets use different APIs
That's not entirely true. There are some additional functions for use with sockets, but you can use, e.g., normal read() and write() on a socket fd.
how does this "Everything is a file" apply here?
In the sense that a file descriptor is involved.
If your definition of "file" is a discrete sequence of bytes stored in a ...
“CPU(s): 56” represents the number of logical cores, which equals “Thread(s) per core” × “Core(s) per socket” × “Socket(s)”. One socket is one physical CPU package (which occupies one socket on the motherboard); each socket hosts a number of physical cores, and each core can run one or more threads. In your case, you have two sockets, each containing a 14-...
To cause an exiting connection to timeout you can use iptables. Just enable a DROP rule on the port you want to disable. So to simulate a timeout for your Samaba server, while an active connection is up, execute the following on the server:
sudo iptables -A INPUT -p tcp --dport 445 -j DROP
The DROP target will not reply with a RST packet or ICMP error to ...
You can use socat for a simple UNIX socket speed test.
Below are the results I get on my laptop:
#Generate 1GB random file in the "shared memory" (i.e. RAM disk)
>dd if=/dev/urandom of=/dev/shm/data.dump bs=1M count=1024
Memory to disk (SSD), through UNIX socket
>socat -u -b32768 UNIX-LISTEN:/tmp/unix.sock ./data.dump &
>socat -u -b32768 "...
The first answer is correct, but I've discovered how these timeouts work, so you could observe and test them (don't forget to block the port!).
There are 4 most interesting kernel parameters that deal with TCP timeouts:
According to the coreutils documentation under --classify (alias -F),
= is for sockets:
Append a character to each file name indicating the file type. Also, for regular files that are executable, append ‘*’. The file type indicators are ‘/’ for directories, ‘@’ for symbolic links, ‘|’ for FIFOs, ‘=’ for sockets, ‘>’ for doors, and nothing for regular ...
They are commonly found in /tmp or a subdirectory thereof. Note that everything in /tmp is subject to erasure at shutdown -- not that it necessarily is erased, just beware that it can be, so if you use that, check if you have to create your subdirectory each time. You will want to use a subdirectory if you want to restrict access via permissions, since /...
In most environments, you would only expect to find tcp, udp, raw and packet sockets. Happily, ss knows about all of these.
Assuming ss knows all the protocols you need it to, I might use the following command. This will exclude the "unix" sockets. It also excludes "netlink" sockets, which are only used to communicate with the local kernel.
sudo ss -l -...
What would have installed/started this service
The debian installer.
I was also surprised to find it enabled because
I did not ask for it
I was not told it would have been running
It is a security risk
Not many people use NFS nowdays
and what do I need to do to disable the appropriate rcp.statd and NFS daemons?
update-rc.d nfs-common disable
What and where is file per each socket?
"Everything" is an exaggeration. It's not a strict policy, it's just a common practice to use the filesystem for interfaces since filesystem access is synonymous with system calls (i.e., the filesystem is really an interface with the kernel, and so provides a convenient format for all kinds of things). Other ...
Now, what is it?
A socket, or "socket" can be several things:
First of all, it is a thought model and an application programming interface (API). That means you have a set of rules you need to follow and a set of functions that you can use to write programs that do something, according to a precisely specified contract. In this particular case, something ...
sockets are a kernel API for communication. Using the socket API, you can exchange data between two endpoints over TCP/IP connections, SCTP associations, UDP datagrams, or between two processes (datagram or connection) using Unix domain sockets...
Being a kernel API, any interaction with a socket is via system calls (socket, bind, connect, listen, accept, ...
"Everything is a file" is just an overstatement. It was novel in 1970s and it was a primary distinguishing characteristic of UNIX. But it's just a marketing concept, not a real foundation of UNIX, because it's obviously not true. It's not beneficial or sensible to treat EVERYTHING as a file.
Is CPU a file? Does your program read() a CPU to get a new ...