Skip to main content
38 votes

What is the difference between Unix sockets and TCP/IP sockets?

What's the difference between Unix socket and TCP/IP socket? A TCP/IP socket is used for communication across TCP/IP networks. A connected TCP socket is identified by the combination of local IP, ...
Peter Green's user avatar
  • 4,494
27 votes

Create Unix Named Socket from the Command Line

I simply use netcat and stay listening in such a case: nc -lkU aSocket.sock you should use netcat-openbsd. netcat-traditional does not have -U switch which is for Unix Domain socket.
Karimai's user avatar
  • 371
21 votes

Create Unix Named Socket from the Command Line

You can use python: python -c "import socket as s; sock = s.socket(s.AF_UNIX); sock.bind('/tmp/test.sock')" Also C, see this answer.
akostadinov's user avatar
  • 1,297
17 votes

linux : netstat listening queue length

Let's look into source code, as it's the best documentation in the world of open source. net/ipv4/tcp_diag.c: if (sk->sk_state == TCP_LISTEN) { r->idiag_rqueue = sk->sk_ack_backlog; ...
Alexander's user avatar
  • 456
10 votes

How to forcibly close a socket in TIME_WAIT?

Yes, there is. You can use ss to immediately destroy all sockets that are in TIME-WAIT state like this: ss state time-wait sport = 49200 -K After that, restarting your listener should succeed instead ...
maxschlepzig's user avatar
  • 1,224
6 votes

Linux command to wait for a SSH server to be up

This is a 'ping_ssh' script I'm using. It handles timeout cases, fast success, and won't prompt for passwords or be fooled by the port being open but not responding as with 'nc' based solutions. This ...
poleguy's user avatar
  • 241
6 votes

Bind a tcp socket below 1000 with a non root user using Systemd, java and Ubuntu 16.04

You’re not actually using the systemd-provided socket in your daemon. Instead of creating a new ServerSocket, use System.inheritedChannel() and check if it’s a ServerSocketChannel. If yes, you ...
Lucas Werkmeister's user avatar
6 votes
Accepted

How do i connect to remote Potgresql server via Unix Doman Socket over SSH

psql -h takes the directory name where it creates the unix domain socket with a name based on some hard coded scheme, i.e. .s.PGSQL.5432 by default based on the default port 5432 when doing ...
Steffen Ullrich's user avatar
5 votes

Uwsgi and flask with unix socket instead of URL

Since this is the first result on Google for how to bind a flask UWSGI app to a unix socket, here is the answer to the question in the title. From flask: app.run(host="unix:///tmp/app.sock") ...
I.Am.A.Guy's user avatar
5 votes

Unix socket vs TCP/IP host:port

On my machine, Ryzen 3900X, Ubuntu 22, A basic C++ TCP server app that only sends 64K packets, and a basic c++ receiver that pulls 100GB of these packets and copies them to it's internal buffer only, ...
George Rey's user avatar
5 votes

Linux command to wait for a SSH server to be up

Something simple like this does the job, waiting 5 seconds between attempts and discarding STDERR until ssh <host> 2> /dev/null do sleep 5 done
Gary's user avatar
  • 51
5 votes
Accepted

Deactivate default ports of systemd socket activation

You can list the files being used by systemd for the socket by using: $ systemctl cat httpd.socket and on my system this shows (some lines removed to keep it short): # /usr/lib/systemd/system/httpd....
meuh's user avatar
  • 1,678
4 votes

System network buffers leaking/fully used, on Windows x64 with plenty of free RAM. How to diagnose and resolve?

Ok, I had been having the same problem for a while. I found another answer that helped. Run "netstat -ano" from a Command Prompt. In my case, the response was an almost-endless list of connections ...
Jacques's user avatar
  • 41
4 votes

How to determine number of open sockets? VM Resource Issues

with ss netstat is deprecated, its replacement is ss. For your case, ss -pun might be useful that shows UDP (-u) sockets with process information (-p) and doesn't turn port numbers into service ...
Matthias Braun's user avatar
4 votes

Need to increase nginx throughput to an upstream unix socket -- linux kernel tuning?

tl;dr Make sure Unicorn backlog is large (use socket, faster than TCP) listen("/var/www/unicorn.sock", backlog: 1024) Optimise NGINX performance settings, for example worker_connections 10000; ...
Epigene's user avatar
  • 141
4 votes

Nginx keepalive when using a UNIX socket

UNIX sockets are still connections so the nginx keepalive is a cache of these, and it doesn't matter what happens at the lower levels. keepalive here isn't the same as many other tools/services where ...
danblack's user avatar
  • 1,309
4 votes
Accepted

How do I change permissions on a ssh forwarded unix domain socket

Use the StreamLocalBindMask option: StreamLocalBindMask Sets the octal file creation mode mask (umask) used when creating a Unix-domain socket file for local or remote port forwarding. This ...
A.B's user avatar
  • 14.3k
4 votes
Accepted

how does an OS route messages sent to the same port to different sockets?

Each end of the connection has its own IP address and port. The "client" (it's not a client as TCP/IP is peer to peer; it's the initiator) has the source IP and source port on its own system, to which ...
Michael Hampton's user avatar
4 votes
Accepted

Why don't I see the TCP handshake in the HTTP server?

I think you have the wrong expectations where the SYN etc should be visible. These are only flags on the TCP packets and are not part of the actual application payload. But netcat only shows the ...
Steffen Ullrich's user avatar
4 votes
Accepted

Socat - is it possible?

Like this? socat tcp-listen:8080,reuseaddr,fork system:'ls; exec socat - tcp\:localhost\:80' 1st parameter gets ,fork to have socat stay listening for more connections system: is preferred over exec: ...
A.B's user avatar
  • 14.3k
4 votes
Accepted

What IP to assign my NIC in order to receive multicast traffic

Multicast group addresses are never assigned to interfaces. They are only joined, with the OS using IGMP rather than ARP to subscribe to the corresponding packets. As others say in the linked thread, ...
grawity's user avatar
  • 19.5k
3 votes

Create Unix Named Socket from the Command Line

On Linux, it's very simple to create such a program: #include <sys/stat.h> #include <stdio.h> int main(int C, char **V){ int r=0; while(*++V) if (mknod(*V,S_IFSOCK|0666,0)) r=1,perror(*...
Petr Skocik's user avatar
3 votes
Accepted

Apache and PHP-FPM security with mod_proxy_fcgi

AllowOverrideList allows to further restrict .htaccess directives to the specified list. Quote from the docs: When this directive is set to None and AllowOverride is set to None, then ....
fuero's user avatar
  • 9,910
3 votes

How can HTTP work over UDP (in the case of Google's QUIC protocol)?

HTTP is an encoding for verbs and responses. It can run across any transport, TCP, QUIC, SCTP. QUIC is optimized for HTTP/2, but it does work as a generic transport. A problem is that https:// URLs ...
John Mahowald's user avatar
3 votes
Accepted

Is there a "server" version of telnet?

Telnet provides a lot more than would be required for your simple use case: according to Telnet Protocol Specification (RFC 854): The TELNET Protocol is built upon three main ideas: first, the ...
Esa Jokinen's user avatar
  • 54.3k
3 votes

OpenDKIM's UNIX socket and permissions for "others"

Using a umask of 002 likely is influenced by the common default umask of 022 - which is also what the opendkim sample configuration cites. Since opendkim uses one umask setting for both the pidfile ...
maxschlepzig's user avatar
  • 1,224
3 votes

How to share unix domain socket between containers without named volume?

If you can configure the directory of the socket file, you could share only that directory (e.g. /var/run/share), avoiding to share /var/run. if you cannot change the socket directory, you could try ...
J.M. Robles's user avatar
  • 1,160
3 votes

Why am I getting "Connection refused"?

The process on port 4296 listens only on the localhost / 127.0.0.1 address and therefore is not accessible from outside. You have to change the configuration (or the program itself if it's one that ...
MLu's user avatar
  • 26.3k
3 votes

How do I create a python 3 service that uses socket with systemd?

Here is ready to go simple shell deploy commands for your case, you can change directories, name, description of service or script and so on, description is below: Make directory and script itself ...
Aleksandr Chendev's user avatar
3 votes

Failed to get properties: Unit name [email protected] is missing the instance name

Problem is Debian /usr/bin/service-script which tries to activate sockets that belongs to service file and [email protected] is for multi instance MariaDB and can't be activated without a name as error ...
Tuukka Pasanen's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible