🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #14477

Re: IP adrress of a network computer

#14477
From: Remy Lebeau (TeamB)
Date: Mon, 11 Aug 2003 23:13
20 lines
1583 bytes
<Jan Piessens> wrote in message news:3f37ee88@newsgroups.borland.com...

> I have fixed it with the next function:

That is slightly dangerous, as hosthostbyname() will return NULL if it
fails, and then you would be accessing an invalid pointer.  You should
always test return values before you use them, ie:

    void __fastcall TForm1::GetComputerIP(String sHost)
    {
        hostent *phost = gethostbyname(sHost.c_str());
        if( phost )
            Edit2->Text = inet_ntoa(*(in_addr*)phost->h_addr);
        else
            Edit2->Clear();
    }


Gambit
Technical Details
Message-ID: <3f38219f$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f336b2a$1@newsgroups.borland.com> <3f33c2fd@newsgroups.borland.com> <3f37ee88@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,68e5ffe7c328d7f6
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-08-11 16:09:53 PST
From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f336b2a$1@newsgroups.borland.com> <3f33c2fd@newsgroups.borland.com> <3f37ee88@newsgroups.borland.com>
Subject: Re: IP adrress of a network computer
Date: Mon, 11 Aug 2003 16:13:43 -0700
Lines: 22
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 207.175.226.26
Message-ID: <3f38219f$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1060643231 207.175.226.26 (11 Aug 2003 16:07:11 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail