In my current case there was the following problem. The DNS resolution gave me some IP-address, that was far-far away, or even unreachable. The write()
was hanging because no TCP response was ever received from that host.
The problem is solved by setting timeout on send operations via setsockopt
and SO_SNDTIMEO
.