Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#1056361: socat: should provide a way to wait until a listening socket is ready

86 views
Skip to first unread message

Michael Gold

unread,
Nov 21, 2023, 12:30:05 PM11/21/23
to
Package: socat
Version: 1.7.4.4-2
Severity: wishlist

While there are several ways to create listening sockets via socat, I've
been unable to find a good way to make a script wait for socat to set up
that socket. For example, the manual page gives this command:
socat UNIX-LISTEN:/tmp/.X11-unix/X1,fork \
SOCKS4:host.victim.org:127.0.0.1:6000,socksuser=nobody,sourceport=20

I might want to put something like that in a script, and immediately run
"DISPLAY=:1 xmessage test" to use the connection. If I put a "&" at the
end of the socat command, it could fail to listen without me knowing, or
xmessage might fail because it runs before the socket's ready. Adding a
"sleep" command usually works but can't be considered reliable. I guess
with 2 "-d" options I could parse stderr with the shell's "read" command
and look for "] N listening ".

It would be nice to have an easy way to do this. For example, an option
that makes socat spawn a sub-process when ready, and shut down when that
sub-process exits. Another way would be an option to make socat go into
the background when ready (but then a script would have to find some way
to kill it when done with it).

- Michael


-- System Information:
Debian Release: trixie/sid
APT prefers unstable-debug
APT policy: (500, 'unstable-debug'), (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 6.5.0-4-amd64 (SMP w/32 CPU threads; PREEMPT)
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8), LANGUAGE=en_CA:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages socat depends on:
ii libc6 2.37-12
ii libssl3 3.0.12-2
ii libwrap0 7.6.q-32

socat recommends no packages.

socat suggests no packages.

-- no debconf information
signature.asc
0 new messages