<?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 herausbekommen]]></title><description><![CDATA[<p>Also ich hab mir mal ein kleines Serverprogramm geschrieben. Dieses gibt immer die Zeile &quot;Incomming Connection... Connection accepted&quot; aus, wenn eine eingehende Verbindung akzeptiert wurde. Gibt es jetzt auch eine Möglichkeit, die IP der eingehenden Verbindung herauszufinden?</p>
<p>Schonmal Thx, im Voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/140111/ip-herausbekommen</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Jul 2026 03:00:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/140111.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 12 Mar 2006 11:02:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 11:02:39 GMT]]></title><description><![CDATA[<p>Also ich hab mir mal ein kleines Serverprogramm geschrieben. Dieses gibt immer die Zeile &quot;Incomming Connection... Connection accepted&quot; aus, wenn eine eingehende Verbindung akzeptiert wurde. Gibt es jetzt auch eine Möglichkeit, die IP der eingehenden Verbindung herauszufinden?</p>
<p>Schonmal Thx, im Voraus.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014422</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014422</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Sun, 12 Mar 2006 11:02:39 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 12:29:15 GMT]]></title><description><![CDATA[<p>getpeername</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014471</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014471</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Sun, 12 Mar 2006 12:29:15 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 13:00:12 GMT]]></title><description><![CDATA[<p>Ja, die Funktion ist ja schön und gut, aber wie krieg ich nun die IP raus? Also in dem SOCKADDR ist die irgendwie nicht abgelegt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014496</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014496</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Sun, 12 Mar 2006 13:00:12 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 13:09:14 GMT]]></title><description><![CDATA[<p>Prinzipiell gibt ja &quot;accept&quot; die adresse zurück (2. Parameter).<br />
Aber auf den Soket kannst DU ja auch jederzeit &quot;getpeername&quot; aufrufenn um die Adresse zu bekommen...<br />
Oder was ist Dein Problem?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014502</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014502</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 12 Mar 2006 13:09:14 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 13:11:30 GMT]]></title><description><![CDATA[<p>Den Socket hab ich ja, ich will jetzt aber die IP-Adresse desjenigen rausbekommen, der eine Verbindung zu dem Server-Programm aufbaut.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014504</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014504</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Sun, 12 Mar 2006 13:11:30 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 13:13:08 GMT]]></title><description><![CDATA[<p>mit getnameinfo kannst du dann die ip bekommen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014506</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014506</guid><dc:creator><![CDATA[.r]]></dc:creator><pubDate>Sun, 12 Mar 2006 13:13:08 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 13:16:45 GMT]]></title><description><![CDATA[<p>Und &quot;accept&quot; liefert dir direkt die IP-Adresse...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014508</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014508</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 12 Mar 2006 13:16:45 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 13:18:36 GMT]]></title><description><![CDATA[<p>Jochen Kalmbach schrieb:</p>
<blockquote>
<p>Und &quot;accept&quot; liefert dir direkt die IP-Adresse...</p>
</blockquote>
<p>Stimmt doch gar nicht. Das liefert nur die SOCKADDR Struktur.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014511</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014511</guid><dc:creator><![CDATA[.r]]></dc:creator><pubDate>Sun, 12 Mar 2006 13:18:36 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 13:23:02 GMT]]></title><description><![CDATA[<p>Hmmm.... und was enthält die &quot;struct sockaddr&quot;?<br />
<a href="http://msdn.microsoft.com/library/en-us/winsock/winsock/accept_2.asp" rel="nofollow">http://msdn.microsoft.com/library/en-us/winsock/winsock/accept_2.asp</a><br />
<a href="http://msdn.microsoft.com/library/en-us/winsock/winsock/sockaddr_2.asp" rel="nofollow">http://msdn.microsoft.com/library/en-us/winsock/winsock/sockaddr_2.asp</a></p>
<p>PS: Wer nicht in der Lage ist aus einer &quot;sockaddr&quot; eine &quot;lesbare&quot; IP zu machen, sollte mit dem Programmieren aufhören...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014516</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014516</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 12 Mar 2006 13:23:02 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 13:42:35 GMT]]></title><description><![CDATA[<p>Die SOCKADDR enthält bei mir char sa_data[14] und u_short sa_family, soweit ich weißt ist die IP aber in SOCKADDR_IN und ich weiß NICHT wie man aus der addr.sin_addr.s_addr eine IP machen soll(umgekehrt schon).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014529</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014529</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Sun, 12 Mar 2006 13:42:35 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 13:44:24 GMT]]></title><description><![CDATA[<blockquote>
<p>Wer nicht in der Lage ist aus einer &quot;sockaddr&quot; eine &quot;lesbare&quot; IP zu machen, <strong>sollte mit dem Programmieren aufhören</strong>...</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1014534</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014534</guid><dc:creator><![CDATA[gni]]></dc:creator><pubDate>Sun, 12 Mar 2006 13:44:24 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 13:46:18 GMT]]></title><description><![CDATA[<p>Ich hab vor 3h mit dem Thema Internet-Programmierung begonnen, muss man da wohl schon wissen wie man daraus eine IP macht?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014535</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014535</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Sun, 12 Mar 2006 13:46:18 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 13:56:26 GMT]]></title><description><![CDATA[<p>Der Kommentar war nicht auf Dich bezogen... sondern auf die Behauptung, dass &quot;accept&quot; die Adresse nicht zurückliefert...<br />
Das Beispiel zur Umwandlung von sockaddr in einen String ist aber hier drin:<br />
<a href="http://msdn.microsoft.com/library/en-us/winsock/winsock/sockaddr_2.asp" rel="nofollow">http://msdn.microsoft.com/library/en-us/winsock/winsock/sockaddr_2.asp</a><br />
(inet_ntoa)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014545</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014545</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 12 Mar 2006 13:56:26 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 14:06:25 GMT]]></title><description><![CDATA[<p>Ja, accept liefert ja auch nicht die IP zurück sondern kann als 2 Parameter einen Pointer auf eine SOCKADDR entgegennehmen. Die IP steht aber nicht in SOCKKADDR sondern in SOCKADDR_IN!</p>
<p>Und dann weiß ich immernoch nicht wie ich aus saddr.sin_addr.s_addr die IP mache!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014549</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014549</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Sun, 12 Mar 2006 14:06:25 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 14:14:07 GMT]]></title><description><![CDATA[<p>Das steht doch in dem Beispiel!!!!!!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014564</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014564</guid><dc:creator><![CDATA[ps]]></dc:creator><pubDate>Sun, 12 Mar 2006 14:14:07 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 14:17:13 GMT]]></title><description><![CDATA[<p>sockaddr ist die &quot;oberklasse&quot; für jede Art von Adressen (es gibt ja nicht nur IP!). Um welche es sich handelt steht ja dann in &quot;sin_family&quot; drin! Daraufhin kann man dan entsprechend auf den anderen Typ casten...<br />
Also, wenn sin_family ein &quot;AF_INET&quot; ist, dann kannst Du es getroste in sockaddr_in casten...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014567</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014567</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 12 Mar 2006 14:17:13 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 14:27:41 GMT]]></title><description><![CDATA[<p>Juhu! Ich habs kapiert! Nur eins noch: wenn ich inet_ntoa benutze um die Adresse in die IP umzuwandeln, krieg ich immer als IP: 88.255.34.0. Mehrere Leute haben schon auf den Server zugegriffen und dann kommt immer diese IP bei mir.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014576</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014576</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Sun, 12 Mar 2006 14:27:41 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 14:33:06 GMT]]></title><description><![CDATA[<p>Dann hast du einen Fehler in deinem Code.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014583</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014583</guid><dc:creator><![CDATA[ps]]></dc:creator><pubDate>Sun, 12 Mar 2006 14:33:06 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 14:36:24 GMT]]></title><description><![CDATA[<p>Nur ein Teilauszug:</p>
<pre><code class="language-cpp">// Wait for incomming connections
bool SOCKET_Server::run()
{
    if(listen(acceptSocket, 100) == SOCKET_ERROR)
    {
        printf(&quot;Not enough rights to act as a server!\n&quot;);
        return false;
    }
    printf(&quot;Waiting for incomming connections...\n&quot;);

    while(true)
    {
        in_addr saddr;
        connectedSocket = accept(acceptSocket, (SOCKADDR *) &amp;saddr, NULL);
        printf(&quot;Incomming Connection...&quot;);
        if(connectedSocket == INVALID_SOCKET)
        {
            printf(&quot; Could not accept the incomming connection!\n&quot;);
            continue;
        }
        printf(&quot; Connection accepted. &quot;);
        char *IP = inet_ntoa(saddr);
        printf(&quot;(%s)\n&quot;, IP);
        closesocket(connectedSocket);
    }

    return true;
}
</code></pre>
<p>Jetz greif ich auf mich selbst zu und dann müsste kommen:<br />
Incomming connection... Connection accepted. (89.57.10.171)</p>
<p>Dort kommt aber jetzt(schon wieder anders als vorhin:<br />
Incomming connection... Connection accepted. (192.253.34.0)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014587</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014587</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Sun, 12 Mar 2006 14:36:24 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 14:48:10 GMT]]></title><description><![CDATA[<p>Dann musst Du doch mal &quot;getpeername&quot; probieren...<br />
Vermutlich liege ich doch falsch und man muss explizit &quot;getpeername&quot; aufrufen... falls dies so ist, möchte ich mich entschuldigen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014598</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014598</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 12 Mar 2006 14:48:10 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 15:27:22 GMT]]></title><description><![CDATA[<p>Also bei getpeername kommt das selbe raus. Wenn ich das ganze jetzt aber mit OpenWatcom statt mit Dev-C++ kompiliere kommt da nicht mehr die IP von vorhin, sondern: 81.0.0.0. Und ich denke mir die 81 soll hier die Portnummer sein:</p>
<pre><code class="language-cpp">// Start Winsocket 2.0, create the socket and bind it to a port
bool SOCKET_Server::start(int portnumber)
{
    // Start Winsocket 2.0
    WSAStartup(MAKEWORD(2, 0), &amp;wsa);
    printf(&quot;Winsocket 2.0 startet...\n&quot;);

    // Create the socket for accepting connections
    acceptSocket = socket(AF_INET, SOCK_STREAM, 0);
    if(acceptSocket == INVALID_SOCKET)
        return false;
    printf(&quot;Socket for incomming connections created...\n&quot;);

    // Bind the socket to a port
    memset(&amp;addr, 0, sizeof(SOCKADDR_IN));
    addr.sin_family = AF_INET;
    addr.sin_port = htons(portnumber);
    addr.sin_addr.s_addr = ADDR_ANY;
    if(bind(acceptSocket, (SOCKADDR*) &amp;addr, sizeof(SOCKADDR_IN)) == SOCKET_ERROR)
        return false;
    printf(&quot;Socket binded to port: %d\n&quot;, portnumber);

    return true;
}

...

// Try to start the server on port 81
server.start(81);
server.run();
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1014623</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014623</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Sun, 12 Mar 2006 15:27:22 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 16:07:28 GMT]]></title><description><![CDATA[<p>Du solltest auch den passenden Datentyp nehmen!!!<br />
ALso bitte kein in_addr sondern ein sockaddr oder aockaddr_in!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014661</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014661</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 12 Mar 2006 16:07:28 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 16:26:13 GMT]]></title><description><![CDATA[<p>Wenn ich als Datentyp sockaddr nehme, nimmt inet_ntoa den wieder nicht an und casten kann man das auch nicht. Und wenn ich sockaddr_in nehme und bei inet_ntoa saddr.sin_addr lässt sich das ganze zwar kompilieren, aber da steht wieder eine IP, die nicht stimmt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014673</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014673</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Sun, 12 Mar 2006 16:26:13 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Sun, 12 Mar 2006 18:51:23 GMT]]></title><description><![CDATA[<p>Du solltest für &quot;accept&quot; ein &quot;sockaddr_in&quot; nehmen und für &quot;inet_ntoa&quot; den member &quot;sin_addr&quot; aus dem &quot;sockaddr_in&quot;...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1014822</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1014822</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Sun, 12 Mar 2006 18:51:23 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Mon, 13 Mar 2006 18:46:20 GMT]]></title><description><![CDATA[<p>Wenn ich das so mache, kommt immernoch eine falsche IP. Kann es daran liegen, dass ich hinter einem Router bin?</p>
<p>Also der Port den in benutze(81) ist freigegeben.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1015625</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1015625</guid><dc:creator><![CDATA[Dr. C++]]></dc:creator><pubDate>Mon, 13 Mar 2006 18:46:20 GMT</pubDate></item><item><title><![CDATA[Reply to IP herausbekommen on Mon, 13 Mar 2006 18:54:30 GMT]]></title><description><![CDATA[<p>Nein, der Router dürfte damit nichts zu tun haben... es ist ja eine eingehende Verbindung und keine Ausgehende...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1015635</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1015635</guid><dc:creator><![CDATA[Jochen Kalmbach]]></dc:creator><pubDate>Mon, 13 Mar 2006 18:54:30 GMT</pubDate></item></channel></rss>