gawkinet: Special File Fields
1
1 2.1.1 The Fields of the Special File Name
1 -----------------------------------------
1
1 This node explains the meaning of all the other fields, as well as the
1 range of values and the defaults. All of the fields are mandatory. To
1 let the system pick a value, or if the field doesn't apply to the
1 protocol, specify it as '0':
1
1 NET-TYPE
1 This is one of 'inet4' for IPv4, 'inet6' for IPv6, or 'inet' to use
1 the system default (which is likely to be IPv4). For the rest of
1 this document, we will use the generic '/inet' in our descriptions
1 of how 'gawk''s networking works.
1
1 PROTOCOL
1 Determines which member of the TCP/IP family of protocols is
1 selected to transport the data across the network. There are two
1 possible values (always written in lowercase): 'tcp' and 'udp'.
1 The exact meaning of each is explained later in this node.
1
1 LOCALPORT
1 Determines which port on the local machine is used to communicate
1 across the network. Application-level clients usually use '0' to
1 indicate they do not care which local port is used--instead they
1 specify a remote port to connect to. It is vital for
1 application-level servers to use a number different from '0' here
1 because their service has to be available at a specific publicly
1 known port number. It is possible to use a name from
1 '/etc/services' here.
1
1 HOSTNAME
1 Determines which remote host is to be at the other end of the
1 connection. Application-level servers must fill this field with a
1 '0' to indicate their being open for all other hosts to connect to
1 them and enforce connection level server behavior this way. It is
1 not possible for an application-level server to restrict its
1 availability to one remote host by entering a host name here.
1 Application-level clients must enter a name different from '0'.
1 The name can be either symbolic (e.g., 'jpl-devvax.jpl.nasa.gov')
1 or numeric (e.g., '128.149.1.143').
1
1 REMOTEPORT
1 Determines which port on the remote machine is used to communicate
1 across the network. For '/inet/tcp' and '/inet/udp',
1 application-level clients _must_ use a number other than '0' to
1 indicate to which port on the remote machine they want to connect.
1 Application-level servers must not fill this field with a '0'.
1 Instead they specify a local port to which clients connect. It is
1 possible to use a name from '/etc/services' here.
1
1 Experts in network programming will notice that the usual
1 client/server asymmetry found at the level of the socket API is not
1 visible here. This is for the sake of simplicity of the high-level
1 concept. If this asymmetry is necessary for your application, use
1 another language. For 'gawk', it is more important to enable users to
1 write a client program with a minimum of code. What happens when first
1 accessing a network connection is seen in the following pseudocode:
1
1 if ((name of remote host given) && (other side accepts connection)) {
1 rendez-vous successful; transmit with getline or print
1 } else {
1 if ((other side did not accept) && (localport == 0))
1 exit unsuccessful
1 if (TCP) {
1 set up a server accepting connections
1 this means waiting for the client on the other side to connect
1 } else
1 ready
1 }
1
1 The exact behavior of this algorithm depends on the values of the
111 fields of the special file name. When in doubt, ⇒(gawkinet)If this table is too complicated If this table is too complicated, focus on the three lines
11 printed in *bold*. All the examples in ⇒Networking With 'gawk'
Using Networking, use only the patterns printed in bold letters.
1
1 PROTOCOL LOCAL HOST NAME REMOTE RESULTING CONNECTION-LEVEL
1 PORT PORT BEHAVIOR
1 ------------------------------------------------------------------------------
1 *tcp* *0* *x* *x* *Dedicated client, fails if
1 immediately connecting to a
1 server on the other side
1 fails*
1 udp 0 x x Dedicated client
1 *tcp, *x* *x* *x* *Client, switches to
1 udp* dedicated server if
1 necessary*
1 *tcp, *x* *0* *0* *Dedicated server*
1 udp*
1 tcp, udp x x 0 Invalid
1 tcp, udp 0 0 x Invalid
1 tcp, udp x 0 x Invalid
1 tcp, udp 0 0 0 Invalid
1 tcp, udp 0 x 0 Invalid
1
1 Table 2.1: /inet Special File Components
1
1 In general, TCP is the preferred mechanism to use. It is the
1 simplest protocol to understand and to use. Use UDP only if
1 circumstances demand low-overhead.
1