🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #4611

Re: host name to ip

#4611
From: Vladimir Stefanovic
Date: Tue, 18 Jan 2005 14:13
54 lines
2308 bytes
Hi,

This is something I found in my archives, for the rest
search as Mr Hans Galema proposed to you...


   WORD wVersionRequested;
   WSADATA wsaData;

   // Start up WinSock
   wVersionRequested = MAKEWORD( 1, 1 );
   WSAStartup( wVersionRequested, &wsaData );


   hostent *p;
   char s[128];
   char *p2;

   //Get the computer name
   gethostname( s, 128 );
   p = gethostbyname( s );

   Memo1->Lines->Add( p->h_name );
   HostName = AnsiString( p->h_name );

   // Get the IpAddress
   p2 = inet_ntoa( *( (in_addr *)p->h_addr ) );
   Memo1->Lines->Add( p2 );
   HostIP = AnsiString( p2 );

   WSACleanup();



Best regards,
Vladimir Stefanovic
"Hans Galema" <notused@notused.nl> wrote in message 
news:41ed17f1$1@newsgroups.borland.com...
> duncan wrote:
>
>>>Have a look at winsock2.h gethostbyname() and gethostbyaddr().
>
>> have you got any examples on how to use the above
>
> Better seach old newsgroup archives as examples have been posted
> here many times.
>
> http://www.google.com/advanced_group_search?hl=en
>
> Fill in for: Return only messages from the newsgroup: *cppbuilder*
>
> Please try that first.
>
> Hans. 
Technical Details
Message-ID: <41ed1993$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41ecf12e$1@newsgroups.borland.com> <41ecf6cb@newsgroups.borland.com> <41ed15c7$1@newsgroups.borland.com> <41ed17f1$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,5df03dd94d1f099f
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Vladimir Stefanovic" <antivari@po.sbb.co.yu>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <41ecf12e$1@newsgroups.borland.com> <41ecf6cb@newsgroups.borland.com> <41ed15c7$1@newsgroups.borland.com> <41ed17f1$1@newsgroups.borland.com>
Subject: Re: host name to ip
Date: Tue, 18 Jan 2005 15:13:47 +0100
Lines: 56
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
NNTP-Posting-Host: 82.117.212.65
Message-ID: <41ed1993$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1106057619 82.117.212.65 (18 Jan 2005 06:13:39 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail