[TUHS] sockets (was Re: First appearance of named pipes)

Peter Pentchev roam at ringlet.net
Sat Mar 28 21:12:34 AEST 2020


On Thu, Mar 26, 2020 at 01:38:17PM +1100, Dave Horsfall wrote:
> On Wed, 25 Mar 2020, Grant Taylor via TUHS wrote:
> 
> > · netcat's STDOUT to grep's STDIN
> > · grep's STDOUT to netcat's STDIN
> 
> Are you trying to set up a loop of processes or something?  I'm not sure if
> that is even possible, although you can't rule out creative uses of dup2()
> etc...

This can't really be done with netcat, but it's quite easy to do with
socat; here's an example with a trivial program that reads lines from
its standard input and writes a single line to its standard output:

    [roam at straylight ~]$ socat -v tcp4:nimbus.fccf.net:25 exec:./heysmtp.py
    > 2020/03/28 13:09:04.005497  length=48 from=0 to=47
    220 nimbus.fccf.net ESMTP Postfix (Debian/GNU)\r
    < 2020/03/28 13:09:04.018931  length=6 from=0 to=5
    QUIT\r
    > 2020/03/28 13:09:04.035387  length=15 from=48 to=62
    221 2.0.0 Bye\r
    [roam at straylight ~]$

All the output was actually from socat because of the "-v" option
specified.

G'luck,
Peter

-- 
Peter Pentchev  roam@{ringlet.net,debian.org,FreeBSD.org} pp at storpool.com
PGP key:        http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20200328/ee139298/attachment.sig>


More information about the TUHS mailing list