You're confusing two things here.
A socket is a file descriptor - a handle - given to a program so that it can use a network connection in almost the same way it uses files. The socket API is protocol-independent; sockets can be created for IPv4 connections or IPv6 ones, but (given kernel support) also for things like DECnet, AppleTalk, or read Ethernet.
Since the socket API is fairly easy to use but since talking to a process on the same machine using an actual network protocol is rather inefficient, at some point the UNIX domain socket was created to allow use of the socket API without that inefficiency. It also adds some extra features; e.g., it is possible to pass file descriptors to another process over a UNIX domain socket.
When one uses UNIX domain sockets, both processes still hold a socket, one for each side of the connection. The use of the socket is no different from, say, IPv4 sockets, apart from the initial connection setup.
One thing the socket API cannot do without is an address; it is not possible to create a socket without passing it an address to talk to, and this is no different for the UNIX domain socket. Since it's UNIX, where everything is a file anyway, it was decided to make these addresses look like filenames. And since we're already doing that, it makes sense to make these addresses appear in the file system, since that makes it easy to spot them.
Unfortunately, the name given to these things in the file system was also 'UNIX domain socket' (or at least, that's what people started calling them). They're not the actual sockets in the sense of the socket API, however; they couldn't be, since those are just a number. As such, their counterpart in an IPv4 socket is not that number, but instead the IP address and port number of the peer you're talking to.
Occasionally, I'll add that since the socket API doesn't deal with files directly, these filesystem representations aren't strictly necessary. Indeed, Linux has a concept of 'anonymous UNIX domain sockets', which are just that: UNIX domain sockets without any link in the filesystem...
I suspect your problem is more because whatever sends the UDP packets is not adding a newline character the commands (as in they should send "play\n"
and not just "play"
).
In any case, if you want a new TCP connection to be created for each of the UDP packets, you should use udp-recvfrom
instead of udp-listen
in socat
:
socat -u udp-recvfrom:3333,fork tcp:localhost:50000
Then every UDP packet should trigger one TCP connection that is only brought up to send the content of the packet and then closed.
Test by doing:
echo play | socat -u - udp-sendto:localhost:3333
(which sends a UDP packet whose payload contains the 5 bytes "play\n"
).
Best Answer
OpenSSH of a sufficient version (OpenSSH 6.7/6.7p1 (2014-10-06) or higher) can do this, if the SSH is initiated from the client to the server system one could write something like
and then the client would connect to
/path/to/client.sock
and the server would listen at/path/to/server.sock
. You probably will also need to set-o StreamLocalBindUnlink=yes
, seessh_config(5)
.(And please don't use
/tmp
; improper use of/tmp
can lead to local security exploits or denials of service or…)