You can set up a select() loop that checks both the logfile
and the socket for input. But those are a big pain in the
neck to write and maintain. My advice is to look into
using
Poe, which takes care of the gory details
for you. Then you can write your log-tailer and your
udp-server as separate Poe processes.