Home > Archive > AWK > September 2004 > Re: Sockets as filenames.
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: Sockets as filenames.
|
|
| Jürgen Kahrs 2004-09-24, 3:55 am |
| Ian Stirling wrote:
> Or absolutely ideally, for all files in
> awk -f whatever.awk /inet/tcp/... /inet/tcp/... /home/me/file
Now I see what your problem actually was.
/inet/tcp has a meaning inside GNU Awk;
outside (in the realm of any shell) it
has no meaning. But even inside GNU Awk
sockets must be handled differently than
files.
When I started implementing socket access
in GAWK, I actually wanted to implement it
just the way you expected it (access with
"<" and ">"). But our honorable Maintainer
convinced me to implement socket access in
a different way ("|&"). The reasoning goes
like this: GAWK remembers if a "file" was
accessed with "<" or ">". These are one-
directional accesses (either read or write,
but not both). Sockets dont fit into this
scheme, therefore Arnold told me to use the
"|&" syntax, which was prepared for two-
directional access. This really makes sense
from an implementer's perspective.
From a user's perspective, I was never happy
with the "|&" syntax because users (like you)
expect things to work in a uniform way.
> More generally, it'd be nice if everything that could be done
> with ARGV/FILENAME/... to choose the upcoming filenames 'just worked'
> with sockets.
Indeed.
> It already (seems to be from the limited testing) half-way there, with
> normal input processing working just fine, only with the anomaly that
> in this case, two sockets with identical names don't read and write
> correctly.
The files with identical name are not much better.
> On linux at least, /dev/tcp doesn't work.
I think Arnold forgot to mention that /dev/tcp is
a feature of the new Korn Shell (ksh93) and not
a feature of GNU Awk. Therefore, you can expect to
see a working /dev/tcp only if your shell is ksh93
compatible.
| |
| Kenny McCormack 2004-09-24, 8:55 am |
| In article <2rgk3dF1a9f3bU1@uni-berlin.de>,
=?ISO-8859-1?Q?J=FCrgen_Kahrs?= <Juergen.KahrsDELETETHIS@vr-web.de> wrote:
>Ian Stirling wrote:
>
>
>Now I see what your problem actually was.
>/inet/tcp has a meaning inside GNU Awk;
>outside (in the realm of any shell) it
>has no meaning. But even inside GNU Awk
>sockets must be handled differently than
>files.
>
>When I started implementing socket access
>in GAWK, I actually wanted to implement it
>just the way you expected it (access with
>"<" and ">"). But our honorable Maintainer
>convinced me to implement socket access in
>a different way ("|&").
Editorial note: I'm not sure what the exact "state" of this discussion is,
and I don't want to get mired in it. I will just state that I think that
Ian has been arguing in circles with himself, but beyond that I don't care.
I am stepping in only to point out that ">" does work with sockets (as
long, of course, as the communication is one-way). My program contains:
sock="/inet/tcp/..."
print data > sock;close(sock)
and it works just fine.
|
|
|
|
|