modem autoconnect, gethostbyname() hangs

I’ve configured autoconnect to connect a modem automatically on socket calls (Siemens GPRS modem on serial port). The autoconnect works fine and starts pppd and my connection is made :slight_smile:. My chat file, autoconnect file and example source code are shown below.
However, on the socket call that actually initiates the autoconnect (whan I’m presently unconnected and pppd is not running) - in this case the initiating call is gethostbyname() - this function blocks and does not return (until after a long system-defined timeout of several minutes). So, the autoconnect is actually initiating and completing - within about 12 seconds of the gethostbyname() call - I can see this with an ifconfig utility call on a terminal - but gethostbyname() is stuck. If I stop the program and start it then it works quite happily since the connection is already made.
Any ideas? I’ll look for some other calls to make that can also lead to autoconnect and test those when I’m next near my QNX machine.

Thanks

Pete

/etc/chat file:

“” ATZ
ABORT BUSY ABORT ‘NO DIALTONE’ ABORT ‘NO CARRIER’ ABORT ERROR OK ATM0
ABORT BUSY ABORT ‘NO DIALTONE’ ABORT ‘NO CARRIER’ ABORT ERROR OK at+cgdcont=1,ip,internet
ABORT BUSY ABORT ‘NO DIALTONE’ ABORT ‘NO CARRIER’ ABORT ERROR OK ATDT99**1#
ABORT BUSY ABORT ‘NO DIALTONE’ ABORT ‘NO CARRIER’ ABORT ERROR CONNECT “”

autoconnect script file:
pppd connect “chat -v -f /etc/chat” debug defaultroute resconf require-ns updetach noipdefault logstatus /dev/ser1 name web
exit

example application code:

int fd;
struct sockaddr_in addr;
struct hostent *hent;

fd = socket(AF_INET, SOCK_STREAM, 0);
if(fd == -1)
{
… errorstuff
return - 1 ;
}

hent = gethostbyname(hname); /* blocks here on autoconnect */

This problem manifests in 6.2.1 NC.

After connection, check your /etc/resolve.conf and “getconf CS_RESOLVER”, check
to see if your DNS has been set up properly.

Also, can you “ping” the DNS ip address at this point?

Can you “ping” some well known ip address (say, find out ip of yahoo.com, and
ping the IP) ?

Fixed…

A nameserver gets added to /etc/resolv.conf during the program execution, so I know that autoconnect is working.

running getconf _CS_RESOLVE several times after the start of the program execution showed the new name server being added after the expected time lapse for dialing and pppd negotiations. It also showed some old nameserver IP addresses from previous ethernet connections. The program at this point was still exhibiting the unwanted blocking behaviour after pppd was up and running.

I cleared out all the nameserver addresses using phlip then started again. This time the program worked correctly and gethostbyname() blocked only until the connection was made. So, the old nameserver addresses seem to have spoilt things, it would appear?

Thanks for your help