<?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[zeiger, klassen und addrinfo]]></title><description><![CDATA[<p>hallo,</p>
<p>ich habe eine klasse mit diesem konstruktor.</p>
<pre><code class="language-cpp">connection::connection(const string&amp; host, const string&amp; port, const addrinfo&amp; hints)
{
    // struct addrinfo** addrlist; ist in der klasse private deklariert.
    int err = getaddrinfo(host.c_str(), port.c_str(), &amp;hints, addrlist);
    if (err != 0)
    {
        throw invalid_argument(&quot;getaddrinfo has returned: &quot; + string(gai_strerror(err)) + &quot; &lt;&quot; + host + &quot;:&quot; + port + &quot;&gt;&quot;);
    }
    if (addrlist == NULL)
    {
        cout &lt;&lt; &quot;addrlist == NULL&quot; &lt;&lt; endl;
    }

}
</code></pre>
<p>und rufe den konstruktor dann auf</p>
<pre><code class="language-cpp">struct addrinfo hints; // suchkreterien
memset(&amp;hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;

connection* metager = new connection(&quot;www.metager.de&quot;, &quot;80&quot;, hints);
connection  fedora(&quot;fedoraproject.org&quot;, &quot;80&quot;, hints);
</code></pre>
<p>warum ist beim anlegen von metager addrlist == NULL<br />
und beim anlegen von fedora nicht mal vorhanden (speicherzugriffsfehler)?</p>
<p>wie würde es funktionieren?</p>
<p>thx</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/204545/zeiger-klassen-und-addrinfo</link><generator>RSS for Node</generator><lastBuildDate>Thu, 08 Oct 2026 16:27:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/204545.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 04 Feb 2008 16:35:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to zeiger, klassen und addrinfo on Mon, 04 Feb 2008 16:38:43 GMT]]></title><description><![CDATA[<p>hallo,</p>
<p>ich habe eine klasse mit diesem konstruktor.</p>
<pre><code class="language-cpp">connection::connection(const string&amp; host, const string&amp; port, const addrinfo&amp; hints)
{
    // struct addrinfo** addrlist; ist in der klasse private deklariert.
    int err = getaddrinfo(host.c_str(), port.c_str(), &amp;hints, addrlist);
    if (err != 0)
    {
        throw invalid_argument(&quot;getaddrinfo has returned: &quot; + string(gai_strerror(err)) + &quot; &lt;&quot; + host + &quot;:&quot; + port + &quot;&gt;&quot;);
    }
    if (addrlist == NULL)
    {
        cout &lt;&lt; &quot;addrlist == NULL&quot; &lt;&lt; endl;
    }

}
</code></pre>
<p>und rufe den konstruktor dann auf</p>
<pre><code class="language-cpp">struct addrinfo hints; // suchkreterien
memset(&amp;hints, 0, sizeof(hints));
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = IPPROTO_TCP;

connection* metager = new connection(&quot;www.metager.de&quot;, &quot;80&quot;, hints);
connection  fedora(&quot;fedoraproject.org&quot;, &quot;80&quot;, hints);
</code></pre>
<p>warum ist beim anlegen von metager addrlist == NULL<br />
und beim anlegen von fedora nicht mal vorhanden (speicherzugriffsfehler)?</p>
<p>wie würde es funktionieren?</p>
<p>thx</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1449199</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1449199</guid><dc:creator><![CDATA[solito]]></dc:creator><pubDate>Mon, 04 Feb 2008 16:38:43 GMT</pubDate></item><item><title><![CDATA[Reply to zeiger, klassen und addrinfo on Mon, 04 Feb 2008 16:44:26 GMT]]></title><description><![CDATA[<p>Probiers so:</p>
<pre><code class="language-cpp">// struct addrinfo* addrlist; ist in der klasse private deklariert.
int err = getaddrinfo(host.c_str(), port.c_str(), &amp;hints, &amp;addrlist);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1449208</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1449208</guid><dc:creator><![CDATA[simon.gysi]]></dc:creator><pubDate>Mon, 04 Feb 2008 16:44:26 GMT</pubDate></item><item><title><![CDATA[Reply to zeiger, klassen und addrinfo on Mon, 04 Feb 2008 16:48:48 GMT]]></title><description><![CDATA[<p>vielen Dank simon.gysi</p>
<p>super</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1449211</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1449211</guid><dc:creator><![CDATA[solito]]></dc:creator><pubDate>Mon, 04 Feb 2008 16:48:48 GMT</pubDate></item></channel></rss>