bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

UDP client programming


From: Henri Moreau
Subject: UDP client programming
Date: Fri, 10 Apr 2009 08:06:17 -0400

My script sends a UDP query to a server and gets a response datagram.  All
packets are character strings and I have had trouble reading the response.
A method that I have found to work is to arrange for the response packet to
have a unique terminating character ('\0') and to pipe the response into a
trivial gawk script with RS="\0".  Simpler methods such as using read or cat
fail.  For read, "read -n1" will read one character but "read -nx", x!=1
just hangs.  Piping the response into cat reads the response but the
pipeline does not terminate so my script cannot continue.  I would like to
know if there are tricks and tips for using sockets more effectively in
bash.  My search on the topic often simply advises users to keep away from
bash networking.

HM






reply via email to

[Prev in Thread] Current Thread [Next in Thread]