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, ...
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.
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.
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;
...
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 ...
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 ...
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 ...
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 ...
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")
...
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, ...
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
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....
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 ...
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 ...
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;
...
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 ...
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 ...
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 ...
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 ...
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: ...
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, ...
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(*...
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 ....
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 ...
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
...
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 ...
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 ...
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 ...
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
...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
socket × 579linux × 115
nginx × 75
networking × 66
tcp × 56
mysql × 44
node.js × 33
ubuntu × 27
port × 26
apache-2.2 × 25
php-fpm × 24
unix × 23
python × 22
linux-networking × 19
windows × 18
debian × 18
java × 18
netstat × 18
php × 16
ssl × 16
tcpip × 16
centos × 15
systemd × 15
port-forwarding × 15
iptables × 14