<?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[Problem mit gethostbyname]]></title><description><![CDATA[<p>Hi!<br />
Wie ja schon der Titel sagt, habe ich Probleme mit der gethostbyname()-Funktion. Ich bin der Meinung es richtig eingesetzt zu haben, allerdings scheint in &quot;phe&quot; kein Rückgabewert gespeichert zu werden. Also scheinbar kommt von gethostbyname() nur NULL zurück, da die if ausgeführt wird.</p>
<p>Was die Einbindungen angeht, habe ich folgendes drin:</p>
<pre><code class="language-cpp">#include &lt;string&gt;
#include &lt;iostream&gt;
#pragma comment(lib, &quot;Ws2_32.lib&quot;) 
#include &lt;winsock2.h&gt;
</code></pre>
<p>Der Code lautet wie folgt: (Es ist ein Ausschnitt eines Konstruktors, daher &quot;exit(0)&quot; statt &quot;return 0&quot;)</p>
<pre><code class="language-cpp">string world;
	cin &gt;&gt; world;

	hostent* phe = gethostbyname(world.c_str());
	if(phe == NULL)
    {
        cout &lt;&lt; &quot;Host konnte nicht aufgeloest werden!&quot; &lt;&lt; endl;
        exit(0);
    }
</code></pre>
<p>Danke schonmal für jede Hilfe.<br />
LG</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/273750/problem-mit-gethostbyname</link><generator>RSS for Node</generator><lastBuildDate>Thu, 27 Aug 2026 23:40:41 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/273750.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 12 Sep 2010 20:32:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem mit gethostbyname on Sun, 12 Sep 2010 20:32:55 GMT]]></title><description><![CDATA[<p>Hi!<br />
Wie ja schon der Titel sagt, habe ich Probleme mit der gethostbyname()-Funktion. Ich bin der Meinung es richtig eingesetzt zu haben, allerdings scheint in &quot;phe&quot; kein Rückgabewert gespeichert zu werden. Also scheinbar kommt von gethostbyname() nur NULL zurück, da die if ausgeführt wird.</p>
<p>Was die Einbindungen angeht, habe ich folgendes drin:</p>
<pre><code class="language-cpp">#include &lt;string&gt;
#include &lt;iostream&gt;
#pragma comment(lib, &quot;Ws2_32.lib&quot;) 
#include &lt;winsock2.h&gt;
</code></pre>
<p>Der Code lautet wie folgt: (Es ist ein Ausschnitt eines Konstruktors, daher &quot;exit(0)&quot; statt &quot;return 0&quot;)</p>
<pre><code class="language-cpp">string world;
	cin &gt;&gt; world;

	hostent* phe = gethostbyname(world.c_str());
	if(phe == NULL)
    {
        cout &lt;&lt; &quot;Host konnte nicht aufgeloest werden!&quot; &lt;&lt; endl;
        exit(0);
    }
</code></pre>
<p>Danke schonmal für jede Hilfe.<br />
LG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1951733</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1951733</guid><dc:creator><![CDATA[One-Man-Army]]></dc:creator><pubDate>Sun, 12 Sep 2010 20:32:55 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit gethostbyname on Sun, 12 Sep 2010 20:53:28 GMT]]></title><description><![CDATA[<p>Mei, is halt n Fehler aufgetreten. Schau halt, welcher...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1951736</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1951736</guid><dc:creator><![CDATA[Horde]]></dc:creator><pubDate>Sun, 12 Sep 2010 20:53:28 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit gethostbyname on Sun, 12 Sep 2010 21:00:54 GMT]]></title><description><![CDATA[<p>Danke für die wirklich sehr hilfreiche Antwort. -.-</p>
<p>Ich dachte eig mir könnte vielleicht jemand sagen, was ich genau da testen kann. Weil bei meinen Tests kommt da kein Grund raus, weswegen ich nichtmal <a href="http://www.google.de" rel="nofollow">www.google.de</a> finde.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1951739</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1951739</guid><dc:creator><![CDATA[One-Man-Army]]></dc:creator><pubDate>Sun, 12 Sep 2010 21:00:54 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit gethostbyname on Sun, 12 Sep 2010 21:30:37 GMT]]></title><description><![CDATA[<ol>
<li><code>gethostbyname</code> ist eine WinAPI Funktion und hat nichts mit Standard C++ zu tun. Daher bist du im falschen Forum.<br />
2. Immer die Dokumentation zu einer Funktion lesen:<br />
<a href="http://msdn.microsoft.com/en-us/library/ms738524.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms738524.aspx</a><br />
Dort steht auch, was man tun muss, wenn man NULL zurückbekommt, also wie man an die Fehlermeldung kommt.</li>
<li><code>exit(0)</code> in einem Konstruktor? Eine ganz schlechte Idee!<br />
3.1 <code>exit(0)</code> bedeutet, dass das Programm ohne Fehler beendet wurde.<br />
3.2 Die <code>exit</code> -Funktion ruft keine Destruktoren auf.<br />
3.3 Exceptions verwenden!</li>
<li><code>std::cin</code> Eingabe in einem Konstruktor? Erscheint mir sehr fragwürdig.</li>
</ol>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1951745</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1951745</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Sun, 12 Sep 2010 21:30:37 GMT</pubDate></item><item><title><![CDATA[Reply to Problem mit gethostbyname on Mon, 13 Sep 2010 09:14:41 GMT]]></title><description><![CDATA[<p>Dravere schrieb:</p>
<blockquote>
<p>2. Immer die Dokumentation zu einer Funktion lesen:<br />
<a href="http://msdn.microsoft.com/en-us/library/ms738524.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms738524.aspx</a><br />
Dort steht auch, was man tun muss, wenn man NULL zurückbekommt, also wie man an die Fehlermeldung kommt.</p>
</blockquote>
<p>Wobei man vielleicht auch direkt den Anfang beachten sollte:</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>getaddrinfo gibt's im Übrigen auch für POSIX/Unix Syteme.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1951857</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1951857</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Mon, 13 Sep 2010 09:14:41 GMT</pubDate></item></channel></rss>