[Top] [All Lists]

UDP client programming

Subject: UDP client programming
From: "Henri Moreau"
Date: Fri, 10 Apr 2009 08:06:17 -0400
Newsgroups: gnu.bash.bug
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.


<Prev in Thread] Current Thread [Next in Thread>