There are a few ways to handle this, and it partly depends on what you're wanting. Chances are your hang is due to the system blocking your read call when there's nothing to be read. Any way you can keep this from happening will probably work.
If you go with alarm(), I'd probably either not handle the signal or just use the handler to clean up a bit. There are better ways to handle the case of nothing to read on a socket. Still, if your network glitches are infrequent but usually last a while, alarm() is probably your best bet. No reason to waste cycles and memory for a process to try to recover if the network's not back up soon.
If your network glitches are short, using nonblocking reads or the select() function may be your best option. With a nonblocking read, you just check to see if you're getting as much data as you expected, and loop with a sleep() or something until you do. The select() function (four-argument version) lets you see if there's anything to read before trying the read. If there's nothing to read, your program can log that info and sleep a while. You'd still want to check the amount of data you're getting once you do perform a read.