GNU Info

Info Node: (gawkinet.info)File /inet/tcp

(gawkinet.info)File /inet/tcp


Next: File /inet/udp Prev: Comparing Protocols Up: Comparing Protocols
Enter node , (file) or (file)node

`/inet/tcp'
...........

   Once again, always use TCP.  (Use UDP when low-overhead is a
necessity, and use RAW for network experimentation.)  The first example
is the sender program:

     # Server
     BEGIN {
       print strftime() |& "/inet/tcp/8888/0/0"
       close("/inet/tcp/8888/0/0")
     }

   The receiver is very simple:

     # Client
     BEGIN {
       "/inet/tcp/0/localhost/8888" |& getline
       print $0
       close("/inet/tcp/0/localhost/8888")
     }

   TCP guarantees that the bytes arrive at the receiving end in exactly
the same order that they were sent. No byte is lost (except for broken
connections), doubled, or out of order. Some overhead is necessary to
accomplish this, but this is the price to pay for a reliable service.
It does matter which side starts first. The sender/server has to be
started first, and it waits for the receiver to read a line.


automatically generated by info2www version 1.2.2.9