Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to send a small string to statsd via nc inside of a read block:

while read line; do
    printf "folder.counter:value|1c" | nc -q 0 -u $host $port
done

Unfortunately, when in UDP mode, nc seems to want to wait indefinitely, even though I've specified -q 0, which the man page says will make the program exit immediately after EOF.

I've tried passing -w 1, but if the data I'm sending comes in at more than one line per second, the data buffers up, and I lose my real time stats (not to mention risking a buffer overflow of some sort).

Is it possible to do what I'm trying to do with netcat, or am I going to need to write something in language which has a statsd library?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I ended up fixing the problem by switching to socat:

while read line; do
    printf "folder.counter:value|1c" | socat -t 0 - UDP:$host:$port
done
share|improve this answer
    
As there's been no other input, and this resolved my problem, I'm marking it as the answer. –  bshacklett Apr 15 '13 at 13:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.