I'm having some trouble with NetLibGetHostByName, namely (heh) that it
corrupts the heap if it fails. Looking at the documentation for this call,
the initialisation values for the various pointers are not specified. I'm
thinking that that may be my problem. After some initial trouble with it
(ie crashes all the time) I started zeroing out the pointers, which seems
to work, well at least when the call itself works.

Here is my current code for this call -

        Err     errCode;
        NetHostInfoBufType      domainInfo;

        for (int i = 0; i < netDNSMaxAddresses; i++)
        {
                domainInfo.addressList [i] = 0L;
        }

        NetHostInfoPtr  result = NetLibGetHostByName
                (PNetLib::Get ().GetRefNum (), (char *) inHostName.CString (),
                        &domainInfo, AppNetTimeout, &errCode);

        if (result == 0)
        {
                throw PSocketExceptionFactory::MakeException
                        ("NetLibGetHostByName", errCode);
        }

        NetIPAddr       *address = (NetIPAddr *) (result->addrListP [0]);

        mAddress = *address;

Has anyone had any trouble with this call? I'd appreciate some pointers
(heh, heh) here.

Thanks in advance.

Jason Proctor
Sr Engineer
Bear River

Reply via email to