<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Eigene IP auslesen]]></title><description><![CDATA[<p>Hallo</p>
<p>ich suche eine Möglichkeit, meine eigene IP auszulesen. Praktisch die, die man mit ipconfig herausbekommt. Bisher hat nur das formatierte auslesen von 'ipconfig &gt;&gt; ip.txt' zum Erfolg geführt, wovon ich aber dringend weg möchte.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/105297/eigene-ip-auslesen</link><generator>RSS for Node</generator><lastBuildDate>Sat, 02 May 2026 07:19:04 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/105297.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 29 Mar 2005 07:17:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Eigene IP auslesen on Tue, 29 Mar 2005 07:17:21 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>ich suche eine Möglichkeit, meine eigene IP auszulesen. Praktisch die, die man mit ipconfig herausbekommt. Bisher hat nur das formatierte auslesen von 'ipconfig &gt;&gt; ip.txt' zum Erfolg geführt, wovon ich aber dringend weg möchte.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/754627</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/754627</guid><dc:creator><![CDATA[derBob]]></dc:creator><pubDate>Tue, 29 Mar 2005 07:17:21 GMT</pubDate></item><item><title><![CDATA[Reply to Eigene IP auslesen on Tue, 29 Mar 2005 07:38:30 GMT]]></title><description><![CDATA[<p>meiner meinung nach kann man die ip mit gethostbyname(&quot;&quot;) rausbekommen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/754641</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/754641</guid><dc:creator><![CDATA[Horst2]]></dc:creator><pubDate>Tue, 29 Mar 2005 07:38:30 GMT</pubDate></item><item><title><![CDATA[Reply to Eigene IP auslesen on Tue, 29 Mar 2005 08:04:53 GMT]]></title><description><![CDATA[<p>Schon richtig, aber mit gethostbyname bekommst du ja nur die IP des übergebenen Hosts (z.B. gethostbyname(&quot;localhost&quot;) -&gt; returnes 127.0.0.1). Wenn es aber darum geht, welche IP der Computer gerade benutzt muss meines Wissens nach eine andere Funktion her, bzw. ein anderes &quot;Funktionsgerüst&quot;.</p>
<p>Schau mal bei BytesAndMore unter C++-Builder -&gt; Netzwerk -&gt; Die IP-Addressen des Computers auslesen:<br />
<a href="http://www.bytesandmore.de/rad/index.htm" rel="nofollow">http://www.bytesandmore.de/rad/index.htm</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/754666</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/754666</guid><dc:creator><![CDATA[Reyx]]></dc:creator><pubDate>Tue, 29 Mar 2005 08:04:53 GMT</pubDate></item><item><title><![CDATA[Reply to Eigene IP auslesen on Tue, 29 Mar 2005 08:11:15 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/7397">@Reyx</a>: mit gethostbyname(&quot;&quot;) bekommt man die verwendete IP, Horst2 hat also (wieder einmal) Recht.</p>
<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/6345">@Horst2</a>: Jetzt klappt es (komischerweise). Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/754675</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/754675</guid><dc:creator><![CDATA[derBob]]></dc:creator><pubDate>Tue, 29 Mar 2005 08:11:15 GMT</pubDate></item><item><title><![CDATA[Reply to Eigene IP auslesen on Tue, 29 Mar 2005 08:14:17 GMT]]></title><description><![CDATA[<p>Die Adresse vom localhost bekommst du nur, wenn du auch &quot;localhost&quot; als parameter übergibst.</p>
<p>Übergibst du einen leeren String, so ist der eigene Rechner gemeint.<br />
Übergibst du einen anderen Namen, wird der Rechner im Netzwerk gesucht</p>
]]></description><link>https://www.c-plusplus.net/forum/post/754678</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/754678</guid><dc:creator><![CDATA[Horst2]]></dc:creator><pubDate>Tue, 29 Mar 2005 08:14:17 GMT</pubDate></item><item><title><![CDATA[Reply to Eigene IP auslesen on Tue, 29 Mar 2005 08:22:25 GMT]]></title><description><![CDATA[<p>Stimmt, hab' ich verdreht, sorry <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/754685</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/754685</guid><dc:creator><![CDATA[Reyx]]></dc:creator><pubDate>Tue, 29 Mar 2005 08:22:25 GMT</pubDate></item><item><title><![CDATA[Reply to Eigene IP auslesen on Tue, 29 Mar 2005 09:14:25 GMT]]></title><description><![CDATA[<p>Hab noch nie was mit WinSock gemacht und fand's interessant.<br />
Hab eben ein bisschen länger gebraucht... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<pre><code class="language-cpp">#include &lt;stdio.h&gt;
#include &lt;winsock2.h&gt;

int main(void)
{
  WORD Version;
  WSADATA Data;
  int err;

  Version = MAKEWORD( 2, 2 );
  err = WSAStartup(Version, &amp;Data);
  if (err!=0)
  {
    printf(&quot;No suitable WinSock DLL found!\n&quot;);
    return 0;
  }

  if (LOBYTE(Data.wVersion)!=2||HIBYTE(Data.wVersion)!=2)
  {
    printf(&quot;No suitable WinSock DLL found!\n&quot;);
    WSACleanup( );
    return 0; 
  }

  char Hostname[99];
  if(gethostname(Hostname, 100)!=0)
  {
    printf(&quot;Buffer too small!\n&quot;);
    return 0;
  }

  hostent *Hostinfo = gethostbyname(Hostname);

  if(!Hostinfo)
  {
    printf(&quot;Something went wrong...\n&quot;);
    return 0;
  }

  printf(&quot;Hostname:   %s\n&quot;, Hostinfo-&gt;h_name);

  for(int i = 0; Hostinfo-&gt;h_addr_list[i]!=NULL; i++)
  {
    printf(&quot;    IP %i:   %03i.%03i.%03i.%03i\n&quot;, i+1, LOBYTE(Hostinfo-&gt;h_addr_list[i][0]), LOBYTE(Hostinfo-&gt;h_addr_list[i][1]), LOBYTE(Hostinfo-&gt;h_addr_list[i][2]), LOBYTE(Hostinfo-&gt;h_addr_list[i][3]));
  }
  return 0;
}
</code></pre>
<p>Ach ja, laut M$ ist die gethostname() nicht mehr das Wahre:</p>
<p>Microsoft schrieb:</p>
<blockquote>
<p>Note The gethostbyname function has been deprecated by the introduction of the getaddrinfo function. Developers creating Windows Sockets 2 applications are urged to use the getaddrinfo function instead of gethostbyname.</p>
</blockquote>
<p>Ich hoff' dieses Post interessiert noch irgendwen!? *verzweifeltdreinschau*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/754713</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/754713</guid><dc:creator><![CDATA[Swordfish]]></dc:creator><pubDate>Tue, 29 Mar 2005 09:14:25 GMT</pubDate></item><item><title><![CDATA[Reply to Eigene IP auslesen on Tue, 29 Mar 2005 11:52:28 GMT]]></title><description><![CDATA[<p><a class="plugin-mentions-user plugin-mentions-a" href="https://www.c-plusplus.net/forum/uid/8250">@Swordfish</a></p>
<p>Wieso deklarierst Du Hostname mit Länge 99 und übergibst an gethostname() eine Länge von 100...</p>
<pre><code class="language-cpp">char Hostname[99]; 
  if(gethostname(Hostname, 100)!=0)
</code></pre>
<p>... und nur die Prüfung auf == WSAEFAULT bedeutet evtl. zu kleiner Buffer.</p>
<p>Nighthero</p>
]]></description><link>https://www.c-plusplus.net/forum/post/754843</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/754843</guid><dc:creator><![CDATA[Nighthero]]></dc:creator><pubDate>Tue, 29 Mar 2005 11:52:28 GMT</pubDate></item></channel></rss>