March 2018
Beginner to intermediate
416 pages
9h 24m
English
TCP gaurantees that data is received at the other end and in the same order as it was transmitted, so always use TCP.
In the following example, we will create a tcp-server (sender) to send the current date time of the server to the client. The server uses the strftime() function with the coprocess operator to send to the GAWK server, listening on the 8080 port. The remote host and remote port could be any client, so its value is kept as 0.
The server connection is closed by passing the special filename to the close() function for closing the file as follows:
$ vi tcpserver.awk#TCP-ServerBEGIN { print strftime() |& "/inet/tcp/8080/0/0" close("/inet/tcp/8080/0/0") }
Now, open one Terminal and run this program ...
Read now
Unlock full access