From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <4432CA60.6010009@asgaard.homelinux.org> Date: Tue, 4 Apr 2006 21:34:56 +0200 From: =?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?= User-Agent: Thunderbird 1.5 (Windows/20051201) MIME-Version: 1.0 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] netcat, the only stdin/stdout redirector to tcp/udp conns? References: <4432C4EA.10204@gmail.com> In-Reply-To: <4432C4EA.10204@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Topicbox-Message-UUID: 2e8b1c82-ead1-11e9-9d60-3106f5b1d025 Llu=EDs Batlle i Rossell wrote: > I hope this will not be any flame... but I hardly can believe that in a= =20 > normal linux/bsd distribution there isn't any tool for redirecting=20 > stdin/stdout to a (new) tcp/udp connection. I think that=20 > file-descriptor-fans will know something like that... >=20 > The most similar program I found is 'netcat', but in all the versions=20 > I've seen, it makes SO_LINGER with linger active, with a 0 seconds=20 > timeout, making it unusable for a "close() after input EOT"-behaviour.=20 > Moreover, netcat isn't a default as "ls" or "cat". >=20 > Am I missing something? Which is the program I'm expecting to find for=20 > that redirection? >=20 > Thanks in advance! #!/bin/rc port=3D'' host=3D'' proto=3D'tcp' switch($#*) { case 2 host=3D$1 ; port=3D$2 case 3 host=3D$1 ; port=3D$2 ; proto=3D$3 case * echo 'usage: nc ipaddr port [proto=3Dtcp]' exit usage } { id=3D`{read <[0=3D3]} echo $proto connection is $id echo connect $host^'!'^$port >[1=3D3] cat /net/$proto/$id/data & cat >/net/$proto/$id/data =09 }<>[3] /net/$proto/clone Though I'd like to see some improvements on that :-|