This article is a mirror article of machine translation, please click here to jump to the original article.

View: 64|Reply: 0

UNIX Domain Socket (UDS) over TCP communication

[Copy link]
Posted on 3/2/2026 2:03:34 PM | | | |
Requirements: Suppose a program on server A only has UDS listening enabled, what should server B do if it wants to call a program on server A? You can use UNIX Domain Socket (UDS) over TCP to forward a process from server A to server B.

review
The Nginx reverse proxy php-fpm uses UDS to communicate
https://www.itsvse.com/thread-11068-1-1.html

Nginx reverse proxy ASP.NET Core use UDS communication
https://www.itsvse.com/thread-11069-1-1.html

.NET/C# processes communicate between gRPC and Unix domain sockets
https://www.itsvse.com/thread-11051-1-1.html

UNIX domain sockets are a mechanism for inter-process communication based on file paths, rather than files on the file system. Even with SFTP or SSHFS, UNIX domain sockets cannot be accessed over the network.

socat uses UNIX domain sockets

Installation commands:
Start the server

First, let's say a server process /tmp/example-server.sock listens for a server called "server-program". /tmp/example-server.sock If you can connect to this socket from another host and access it, then you can say that you have been able to outperform the network by using it as a UNIX domain socket.

If you just want to test it out, you can use socat.
Test call, the command is as follows:
As shown below:



Or connect using the socat command, as shown below:



Use TCP connections

Use the socat command on the host on which the server process is running.
Connect to TCP from the remote host

It listens for the UNIX domain socket of the same name and connects it to the host on which the server process runs.
Use the client on the remote host

Now that everything is ready, let's connect to the server process over the network. If you want to test it out too, you can use socat.

Use OpenSSH

If you have SSH access, there is an easier way. /tmp/example-server.sock First, start the server host (omitted). Use -L on the client host. The command is as follows:
It is now accessible from the client host.




Previous:Front-end Performance Optimization: Ditch XMLHttpRequest in favor of fetch interfaces
Next:A brief introduction to network ICMP (Internet Control Message Protocol).
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com