in reply to variable timeout

I'm not sure what modules you're using, but if you are doing network I/O without any modules (and maybe if you are using some some modules) you can use timeout of 'select'. Set it to a small value the first time and count the number of times it times out without data. That will give you an idea of how long talking to a particular host takes. Then if it takes, say, 50 times longer than that in the future, you can report the condition or do whatever you plan on doing.