<?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[IP in String]]></title><description><![CDATA[<p>Hallo!<br />
Ich spiele gerade etwas mit Netzwerkzeug (im speziellen UDP) rum ;). Nun komme ich an eine Stelle, an der ich Daten empfange und herausfinden will, von wem die sind:</p>
<pre><code class="language-cpp">recvfrom(mSock, response, 1024, 0, (SOCKADDR*)&amp;mAddrResponse, &amp;mAddrResponseLen);
cout&lt;&lt;mAddrResponse.sin_addr.s_addr&lt;&lt;endl;
</code></pre>
<p>Schön, kein Problem, aber wie wandle ich nun die als unsigned_long gegebene IP-Adresse in einen String der gewohnten Form (X.X.X.X) um?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/166898/ip-in-string</link><generator>RSS for Node</generator><lastBuildDate>Tue, 15 Sep 2026 15:36:26 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/166898.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 04 Dec 2006 10:55:34 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to IP in String on Mon, 04 Dec 2006 10:55:34 GMT]]></title><description><![CDATA[<p>Hallo!<br />
Ich spiele gerade etwas mit Netzwerkzeug (im speziellen UDP) rum ;). Nun komme ich an eine Stelle, an der ich Daten empfange und herausfinden will, von wem die sind:</p>
<pre><code class="language-cpp">recvfrom(mSock, response, 1024, 0, (SOCKADDR*)&amp;mAddrResponse, &amp;mAddrResponseLen);
cout&lt;&lt;mAddrResponse.sin_addr.s_addr&lt;&lt;endl;
</code></pre>
<p>Schön, kein Problem, aber wie wandle ich nun die als unsigned_long gegebene IP-Adresse in einen String der gewohnten Form (X.X.X.X) um?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1186708</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1186708</guid><dc:creator><![CDATA[Evolver]]></dc:creator><pubDate>Mon, 04 Dec 2006 10:55:34 GMT</pubDate></item><item><title><![CDATA[Reply to IP in String on Mon, 04 Dec 2006 11:01:10 GMT]]></title><description><![CDATA[<p>Möglichkeit 1: Die in_addr ist (laut) MSDN eine union aus 4 char's (S_un_b.s_b1 bis S_un_b.s_b4), 2 short (S_un_w.s_w1 und S_un_w.s_w2) oder einem long (S_addr) - du kannst erster nehmen, um die vier Blöcke der IP auszulesen.</p>
<p>Möglichkeit 2: Du verwendest Bit-Shift's und Bit-And, um deinen long-Wert zu zerlegen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1186713</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1186713</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 04 Dec 2006 11:01:10 GMT</pubDate></item><item><title><![CDATA[Reply to IP in String on Mon, 04 Dec 2006 11:13:33 GMT]]></title><description><![CDATA[<p>Möglichkeit 3:</p>
<pre><code class="language-cpp">typedef unsigned long uint32;

std::string ip_to_string(uint32 ip)
{
    std::ostringstream strm;
    unsigned char *bytes = reinterpret_cast&lt;unsigned char *&gt;(&amp;ip);
    strm &lt;&lt; static_cast&lt;uint32&gt;(bytes[0]) &lt;&lt; &quot;.&quot;
        &lt;&lt; static_cast&lt;uint32&gt;(bytes[1]) &lt;&lt; &quot;.&quot;
        &lt;&lt; static_cast&lt;uint32&gt;(bytes[2]) &lt;&lt; &quot;.&quot;
        &lt;&lt; static_cast&lt;uint32&gt;(bytes[3]);

    return strm.str();
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1186724</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1186724</guid><dc:creator><![CDATA[schorsch code]]></dc:creator><pubDate>Mon, 04 Dec 2006 11:13:33 GMT</pubDate></item><item><title><![CDATA[Reply to IP in String on Mon, 04 Dec 2006 11:21:37 GMT]]></title><description><![CDATA[<p>Möglichkeit 4:<br />
Man nehme einfach die dafür gedachten BSD-Socket-Funktionen:</p>
<pre><code class="language-cpp">cout &lt;&lt; inet_ntoa(mAddrResponse.sin_addr) &lt;&lt; endl;
</code></pre>
<p><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>
]]></description><link>https://www.c-plusplus.net/forum/post/1186731</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1186731</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Mon, 04 Dec 2006 11:21:37 GMT</pubDate></item><item><title><![CDATA[Reply to IP in String on Mon, 04 Dec 2006 11:23:24 GMT]]></title><description><![CDATA[<p>Guck dir mal diese Funktionen an:<br />
<a href="http://www.zotteljedi.de/doc/socket-tipps/inet_xxx.html" rel="nofollow">http://www.zotteljedi.de/doc/socket-tipps/inet_xxx.html</a><br />
Sollte genau das sein was du suchst. Zu beachten ist das es inet_ntoa nur in UNIX-Systemen gibt. Für Windows ist inet_addr zu verwenden.</p>
<p>Greetz</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1186732</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1186732</guid><dc:creator><![CDATA[Vellas]]></dc:creator><pubDate>Mon, 04 Dec 2006 11:23:24 GMT</pubDate></item><item><title><![CDATA[Reply to IP in String on Mon, 04 Dec 2006 11:29:13 GMT]]></title><description><![CDATA[<p>Vellas schrieb:</p>
<blockquote>
<p>Zu beachten ist das es inet_ntoa nur in UNIX-Systemen gibt. Für Windows ist inet_addr zu verwenden.</p>
</blockquote>
<p>EDIT: Revision!</p>
<p>Laut MSDN 8.0 ist inet_ntoa sehr wohl in Winsock 2 vorhanden.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1186735</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1186735</guid><dc:creator><![CDATA[LordJaxom]]></dc:creator><pubDate>Mon, 04 Dec 2006 11:29:13 GMT</pubDate></item><item><title><![CDATA[Reply to IP in String on Mon, 04 Dec 2006 11:30:07 GMT]]></title><description><![CDATA[<p>inet_ntoa(mAddrResponse.sin_addr);<br />
Sehr schön, das gefällt mir ;). Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1186736</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1186736</guid><dc:creator><![CDATA[Evolver]]></dc:creator><pubDate>Mon, 04 Dec 2006 11:30:07 GMT</pubDate></item><item><title><![CDATA[Reply to IP in String on Mon, 04 Dec 2006 13:49:35 GMT]]></title><description><![CDATA[<p>LordJaxom schrieb:</p>
<blockquote>
<p>Vellas schrieb:</p>
<blockquote>
<p>Zu beachten ist das es inet_ntoa nur in UNIX-Systemen gibt. Für Windows ist inet_addr zu verwenden.</p>
</blockquote>
<p>EDIT: Revision!</p>
<p>Laut MSDN 8.0 ist inet_ntoa sehr wohl in Winsock 2 vorhanden.</p>
</blockquote>
<p>War auch völliger Blödsinn, es war inet_aton() die es bei MS nicht gibt. Aber ne MSDN-Suche hat dazu bissl was ausgespuckt. U.a. nen Source zu inet_aton():<br />
<a href="http://research.microsoft.com/invisible/src/net/wsock32/inet_add.c.htm" rel="nofollow">http://research.microsoft.com/invisible/src/net/wsock32/inet_add.c.htm</a><br />
Folgender Link ist auch sehr interessant (dort ist u.a. auch inet_aton zu finden):<br />
<a href="http://technet2.microsoft.com/WindowsServer/en/library/5309e1bf-0316-4db3-b1e7-d62db16813041033.mspx?mfr=true" rel="nofollow">http://technet2.microsoft.com/WindowsServer/en/library/5309e1bf-0316-4db3-b1e7-d62db16813041033.mspx?mfr=true</a><br />
MSDN: <a href="http://search.microsoft.com/results.aspx?mkt=en-GB&amp;setlang=en-GB&amp;q=inet_aton" rel="nofollow">http://search.microsoft.com/results.aspx?mkt=en-GB&amp;setlang=en-GB&amp;q=inet_aton</a></p>
<p>Greetz</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1186883</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1186883</guid><dc:creator><![CDATA[Vellas]]></dc:creator><pubDate>Mon, 04 Dec 2006 13:49:35 GMT</pubDate></item></channel></rss>