big problem! gethostbyname() blocks

i noticed that gethostbyname() blocks if the network is down, what should I

there got to be a way to set a timeout on this .

I had similar problems with ‘connect()’, it blocks also, i had to use
fcntl() with O_NONBLOCK flag, then use ‘select’ to set a timeout.