<?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[über winsock zu &amp;quot;google.de&amp;quot; connecten]]></title><description><![CDATA[<p>Hi, ich habe aus einem anderen Topic das hier:</p>
<pre><code class="language-cpp">#include &lt;winsock.h&gt;
#include &lt;stdio.h&gt;

#pragma comment(lib, &quot;Ws2_32.lib&quot;)

u_long test(char *host){

   struct hostent *hp;
   u_long host_ip;

    host_ip = inet_addr(host);
    if(host_ip == INADDR_NONE){
        hp = gethostbyname(host);
        if(!hp){
           printf(&quot;Unable to resolv hostname %s\n&quot;, host);
        }else{
           host_ip = *(u_long *)hp-&gt;h_addr;
       }
    }
    return host_ip;
}

int main(int argc, char *argv[]) {
	printf(&quot;%d&quot;, test(&quot;google.de&quot;));
	getchar();
}
</code></pre>
<p>Ich möchte, dass man die Internetadresse angeben kann, und dahin connected wird.<br />
aber für inet_addr brauch man eine IP<br />
und das da oben, soll, glaub ich, genau das machen.<br />
aber bei mir kommt da immer &quot;unable to re...&quot;</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/180046/über-winsock-zu-quot-google-de-quot-connecten</link><generator>RSS for Node</generator><lastBuildDate>Thu, 09 Jul 2026 13:33:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/180046.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 28 Apr 2007 01:34:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to über winsock zu &amp;quot;google.de&amp;quot; connecten on Sat, 28 Apr 2007 01:34:50 GMT]]></title><description><![CDATA[<p>Hi, ich habe aus einem anderen Topic das hier:</p>
<pre><code class="language-cpp">#include &lt;winsock.h&gt;
#include &lt;stdio.h&gt;

#pragma comment(lib, &quot;Ws2_32.lib&quot;)

u_long test(char *host){

   struct hostent *hp;
   u_long host_ip;

    host_ip = inet_addr(host);
    if(host_ip == INADDR_NONE){
        hp = gethostbyname(host);
        if(!hp){
           printf(&quot;Unable to resolv hostname %s\n&quot;, host);
        }else{
           host_ip = *(u_long *)hp-&gt;h_addr;
       }
    }
    return host_ip;
}

int main(int argc, char *argv[]) {
	printf(&quot;%d&quot;, test(&quot;google.de&quot;));
	getchar();
}
</code></pre>
<p>Ich möchte, dass man die Internetadresse angeben kann, und dahin connected wird.<br />
aber für inet_addr brauch man eine IP<br />
und das da oben, soll, glaub ich, genau das machen.<br />
aber bei mir kommt da immer &quot;unable to re...&quot;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1274927</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1274927</guid><dc:creator><![CDATA[MasterOfPuppets]]></dc:creator><pubDate>Sat, 28 Apr 2007 01:34:50 GMT</pubDate></item><item><title><![CDATA[Reply to über winsock zu &amp;quot;google.de&amp;quot; connecten on Sat, 28 Apr 2007 02:54:36 GMT]]></title><description><![CDATA[<p>du musst winsock vorher initialisieren wahrscheinlich mit WSAStartup oder so aehnlich...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1274936</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1274936</guid><dc:creator><![CDATA[WsaStartup]]></dc:creator><pubDate>Sat, 28 Apr 2007 02:54:36 GMT</pubDate></item><item><title><![CDATA[Reply to über winsock zu &amp;quot;google.de&amp;quot; connecten on Sat, 28 Apr 2007 08:18:33 GMT]]></title><description><![CDATA[<p>WsaStartup schrieb:</p>
<blockquote>
<p>du musst winsock vorher initialisieren wahrscheinlich mit WSAStartup oder so aehnlich...</p>
</blockquote>
<p>Yep !</p>
<p>Z.B. : Diesen ( aus einer alten MSDN kopieten ) Block in main() einfügen<br />
und die hässlichen returns ausbeulen:</p>
<pre><code class="language-cpp">WORD wVersionRequested;
WSADATA wsaData;
int err;

wVersionRequested = MAKEWORD( 2, 0 );

err = WSAStartup( wVersionRequested, &amp;wsaData );
if ( err != 0 ) {
    /* Tell the user that we couldn't find a usable */
    /* WinSock DLL.                                  */
    return;
}

/* Confirm that the WinSock DLL supports 2.0.*/
/* Note that if the DLL supports versions greater    */
/* than 2.0 in addition to 2.0, it will still return */
/* 2.0 in wVersion since that is the version we      */
/* requested.                                        */

if ( LOBYTE( wsaData.wVersion ) != 2 ||
        HIBYTE( wsaData.wVersion ) != 0 ) {
    /* Tell the user that we couldn't find a usable */
    /* WinSock DLL.                                  */
    WSACleanup( );
    return; 
}

/* The WinSock DLL is acceptable. Proceed. */
</code></pre>
<p>Grüsse</p>
<p>Gast++</p>
<p>P.S.: &quot;gethostbyname&quot; soll nach dem VC Express MSDN obsolete sein.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1274976</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1274976</guid><dc:creator><![CDATA[Gast++]]></dc:creator><pubDate>Sat, 28 Apr 2007 08:18:33 GMT</pubDate></item><item><title><![CDATA[Reply to über winsock zu &amp;quot;google.de&amp;quot; connecten on Sat, 28 Apr 2007 08:43:13 GMT]]></title><description><![CDATA[<p>Danke, immerhin kommt jetzt kein Fehler mehr, jedoch wenn ich <a href="http://Google.de" rel="nofollow">Google.de</a> teste kommt ein zusammenhängende Zahl, ohne trennende Punkte heraus, die mit 175 beginnt, und wenn ich Google pinge, kommt etwas ganz anderes heraus, ich dachte diese Funktion ist dazu da, um z.b. &quot;<a href="http://meineseite.com" rel="nofollow">meineseite.com</a>&quot; in eine IP zu konvertieren...<br />
oder stimmt das nicht? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1274985</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1274985</guid><dc:creator><![CDATA[MasterOfPuppets]]></dc:creator><pubDate>Sat, 28 Apr 2007 08:43:13 GMT</pubDate></item><item><title><![CDATA[Reply to über winsock zu &amp;quot;google.de&amp;quot; connecten on Sat, 28 Apr 2007 08:55:04 GMT]]></title><description><![CDATA[<p>in nem u_long gehen auch keine punkte rein</p>
<p><img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1274998</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1274998</guid><dc:creator><![CDATA[vister]]></dc:creator><pubDate>Sat, 28 Apr 2007 08:55:04 GMT</pubDate></item><item><title><![CDATA[Reply to über winsock zu &amp;quot;google.de&amp;quot; connecten on Sat, 28 Apr 2007 09:02:06 GMT]]></title><description><![CDATA[<p>MasterOfPuppets schrieb:</p>
<blockquote>
<p>Danke, immerhin kommt jetzt kein Fehler mehr, jedoch wenn ich <a href="http://Google.de" rel="nofollow">Google.de</a> teste kommt ein zusammenhängende Zahl, ohne trennende Punkte heraus, die mit 175 beginnt, und wenn ich Google pinge, kommt etwas ganz anderes heraus, ich dachte diese Funktion ist dazu da, um z.b. &quot;<a href="http://meineseite.com" rel="nofollow">meineseite.com</a>&quot; in eine IP zu konvertieren...<br />
oder stimmt das nicht? <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
</blockquote>
<p>IP Adressen werden _BYTEWEISE_ dezimal dargestellt (aka &quot;DOTTED DECIMAL NOTATION&quot;).<br />
Lass Dir die Zahl vielleicht mal in Hex anzeigen und und konvertier die _einzelnen_ Bytes ( je 2 Buchstaben bei der Adresse ) in Dezimalzahlen.</p>
<p>Grüsse</p>
<p>Gast++</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1275006</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1275006</guid><dc:creator><![CDATA[Gast++]]></dc:creator><pubDate>Sat, 28 Apr 2007 09:02:06 GMT</pubDate></item><item><title><![CDATA[Reply to über winsock zu &amp;quot;google.de&amp;quot; connecten on Sat, 28 Apr 2007 11:07:13 GMT]]></title><description><![CDATA[<p>Hm, ich weiß nicht ob ich das alleine hinkriege, die angegebene Funktion hab ich auch nur von einem anderen aus dem forum hier übernommen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1275063</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1275063</guid><dc:creator><![CDATA[MasterOfPuppets]]></dc:creator><pubDate>Sat, 28 Apr 2007 11:07:13 GMT</pubDate></item><item><title><![CDATA[Reply to über winsock zu &amp;quot;google.de&amp;quot; connecten on Sat, 28 Apr 2007 11:15:46 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">std::string getIpAddress(const std::string&amp; host)
{
	// Fehlerbehandlung muss noch eingebaut werden

	addrinfo* pAddrinfo;
	getaddrinfo(host.c_str(), NULL, NULL, &amp;pAddrinfo);

	char ipAddressString[NI_MAXHOST];
	getnameinfo(pAddrinfo-&gt;ai_addr, pAddrinfo-&gt;ai_addrlen,
				ipAddressString, sizeof(ipAddressString),
				NULL, 0, NI_NUMERICHOST);

	return ipAddressString;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1275072</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1275072</guid><dc:creator><![CDATA[afg]]></dc:creator><pubDate>Sat, 28 Apr 2007 11:15:46 GMT</pubDate></item></channel></rss>