GNU Info

Info Node: (gawkinet.info)Gawk Special Files

(gawkinet.info)Gawk Special Files


Next: TCP Connecting Prev: Using Networking Up: Using Networking
Enter node , (file) or (file)node

`gawk' Networking Mechanisms
============================

   The `|&' operator introduced in `gawk' 3.1 for use in communicating
with a "co-process" is described in Note: Two-way Communications With
Another Process.  It shows how to do two-way I/O to a
separate process, sending it data with `print' or `printf' and reading
data with `getline'.  If you haven't read it already, you should detour
there to do so.

   `gawk' transparently extends the two-way I/O mechanism to simple
networking through the use of special file names.  When a "co-process"
is started that matches the special files we are about to describe,
`gawk' creates the appropriate network connection, and then two-way I/O
proceeds as usual.

   At the C, C++ (and basic Perl) level, networking is accomplished via
"sockets", an Application Programming Interface (API) originally
developed at the University of California at Berkeley that is now used
almost universally for TCP/IP networking.  Socket level programming,
while fairly straightforward, requires paying attention to a number of
details, as well as using binary data.  It is not well-suited for use
from a high-level language like `awk'.  The special files provided in
`gawk' hide the details from the programmer, making things much simpler
and easier to use.

   The special file name for network access is made up of several
fields, all of them mandatory, none of them optional:

     /inet/PROTOCOL/LOCALPORT/HOSTNAME/REMOTEPORT

   The `/inet/' field is, of course, constant when accessing the
network.  The LOCALPORT and REMOTEPORT fields do not have a meaning
when used with `/inet/raw' because "ports" only apply to TCP and UDP.
So, when using `/inet/raw', the port fields always have to be `0'.

Special File Fields
The fields in the special file name.
Comparing Protocols
Differences between the protocols.

automatically generated by info2www version 1.2.2.9