<?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[Socket klappt nicht]]></title><description><![CDATA[<p>hallo, weiß jemand warum dieser code hier</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;fstream&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;process.h&gt;

using namespace std;

SOCKET connectSocket(SOCKET s, const char* szHostNameOrIp, int port);
int getAddrFromString(const char* hostnameOrIp, SOCKADDR_IN* addr);

static SOCKET s1, s2, s3;
char *szAppName = &quot;appname&quot;;

void Thread1(PVOID pvoid);

// Einstiegspunkt...
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
				   PSTR szCmdLine, int iCmdShow)
{
	// IP oder Hostname einlesen
	string string1;
	ifstream in(&quot;lol.xx&quot;);
	if(!in) 
	{
	    MessageBox(0, &quot;lol.xx nicht gefunden!&quot;, szAppName, MB_ICONERROR);
	    return 0;
	}
	while(!in.eof())
    {
        getline(in, string1);
    }
	// Verbinden
	SOCKET testsock;
	testsock = connectSocket(s1, string1.c_str(), geheimport);
	if(testsock == SOCKET_ERROR)
		return 0;
	testsock = connectSocket(s2, string1.c_str(), geheimport);
	if(testsock == SOCKET_ERROR)
		return 0;
	testsock = connectSocket(s3, string1.c_str(), geheimport);
	if(testsock == SOCKET_ERROR)
		return 0;
	_beginthread (Thread1, 0, 0);
	while(1)
	Sleep(50);
	return 0;
}

SOCKET connectSocket(SOCKET s, const char* szHostNameOrIp, int port)
{
	WSADATA wsa;
	SOCKADDR_IN addr;
	int rc;
	if(WSAStartup(MAKEWORD(2, 0), &amp;wsa) != 0)
	{
		return SOCKET_ERROR;
	}
	s = socket(AF_INET, SOCK_STREAM, 0);
	if(s == INVALID_SOCKET) 
	{
		return SOCKET_ERROR;
	}
	memset(&amp;addr, 0, sizeof(SOCKADDR_IN)); // zuerst alles auf 0 setzten 
	addr.sin_family = AF_INET;
	addr.sin_port = htons(port);
	rc = getAddrFromString(szHostNameOrIp, &amp;addr);
	if(rc == SOCKET_ERROR)
	{
		return SOCKET_ERROR;
	}
    if(connect(s, (SOCKADDR*)&amp;addr, sizeof(SOCKADDR)) == SOCKET_ERROR) 
	{
		return SOCKET_ERROR;
	}
	return 0;
}

int getAddrFromString(const char* hostnameOrIp, SOCKADDR_IN* addr)
{
    unsigned long ip;
    HOSTENT* he;
    if(hostnameOrIp==NULL || addr==NULL) /* Parameter prüfen */
	   	return SOCKET_ERROR;
    ip = inet_addr(hostnameOrIp); /* eine IP in hostnameOrIp ? */
	if(ip != INADDR_NONE) /* bei einem fehler liefert inet_addr den Rückgabewert INADDR_NONE */
    {
		addr-&gt;sin_addr.s_addr = ip;
		return 0;
    }
    else
    {
		he = gethostbyname(hostnameOrIp); /* Hostname in hostnameOrIp auflösen */
		if(he == NULL)
		{
	   		return SOCKET_ERROR;
		}
		else
			memcpy(&amp;(addr-&gt;sin_addr),he-&gt;h_addr_list[0],4); /*die 4 Bytes der IP von he nach addr kopieren */
	}
    return 0;
}

void Thread1(PVOID pvoid)
{
	char format[10];
	char lool[100];
    recv(s1, format, sizeof(format), 0);  // FUnktioniert nicht 
	sprintf(lool, &quot;%d&quot;, WSAGetLastError()); // WSA error 10038
	MessageBox(0, lool, lool, 0);
	_endthread () ;
}
</code></pre>
<p>Socket operation on nonsocket.</p>
<p>An operation was attempted on something that is not a socket. Either the socket handle parameter did not reference a valid socket, or for select, a member of an fd_set was not valid.</p>
<p>was heißt das jetzt genau?<br />
Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/224734/socket-klappt-nicht</link><generator>RSS for Node</generator><lastBuildDate>Sat, 11 Apr 2026 17:09:05 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/224734.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 14 Oct 2008 13:05:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Socket klappt nicht on Tue, 14 Oct 2008 13:05:09 GMT]]></title><description><![CDATA[<p>hallo, weiß jemand warum dieser code hier</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;fstream&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;process.h&gt;

using namespace std;

SOCKET connectSocket(SOCKET s, const char* szHostNameOrIp, int port);
int getAddrFromString(const char* hostnameOrIp, SOCKADDR_IN* addr);

static SOCKET s1, s2, s3;
char *szAppName = &quot;appname&quot;;

void Thread1(PVOID pvoid);

// Einstiegspunkt...
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, 
				   PSTR szCmdLine, int iCmdShow)
{
	// IP oder Hostname einlesen
	string string1;
	ifstream in(&quot;lol.xx&quot;);
	if(!in) 
	{
	    MessageBox(0, &quot;lol.xx nicht gefunden!&quot;, szAppName, MB_ICONERROR);
	    return 0;
	}
	while(!in.eof())
    {
        getline(in, string1);
    }
	// Verbinden
	SOCKET testsock;
	testsock = connectSocket(s1, string1.c_str(), geheimport);
	if(testsock == SOCKET_ERROR)
		return 0;
	testsock = connectSocket(s2, string1.c_str(), geheimport);
	if(testsock == SOCKET_ERROR)
		return 0;
	testsock = connectSocket(s3, string1.c_str(), geheimport);
	if(testsock == SOCKET_ERROR)
		return 0;
	_beginthread (Thread1, 0, 0);
	while(1)
	Sleep(50);
	return 0;
}

SOCKET connectSocket(SOCKET s, const char* szHostNameOrIp, int port)
{
	WSADATA wsa;
	SOCKADDR_IN addr;
	int rc;
	if(WSAStartup(MAKEWORD(2, 0), &amp;wsa) != 0)
	{
		return SOCKET_ERROR;
	}
	s = socket(AF_INET, SOCK_STREAM, 0);
	if(s == INVALID_SOCKET) 
	{
		return SOCKET_ERROR;
	}
	memset(&amp;addr, 0, sizeof(SOCKADDR_IN)); // zuerst alles auf 0 setzten 
	addr.sin_family = AF_INET;
	addr.sin_port = htons(port);
	rc = getAddrFromString(szHostNameOrIp, &amp;addr);
	if(rc == SOCKET_ERROR)
	{
		return SOCKET_ERROR;
	}
    if(connect(s, (SOCKADDR*)&amp;addr, sizeof(SOCKADDR)) == SOCKET_ERROR) 
	{
		return SOCKET_ERROR;
	}
	return 0;
}

int getAddrFromString(const char* hostnameOrIp, SOCKADDR_IN* addr)
{
    unsigned long ip;
    HOSTENT* he;
    if(hostnameOrIp==NULL || addr==NULL) /* Parameter prüfen */
	   	return SOCKET_ERROR;
    ip = inet_addr(hostnameOrIp); /* eine IP in hostnameOrIp ? */
	if(ip != INADDR_NONE) /* bei einem fehler liefert inet_addr den Rückgabewert INADDR_NONE */
    {
		addr-&gt;sin_addr.s_addr = ip;
		return 0;
    }
    else
    {
		he = gethostbyname(hostnameOrIp); /* Hostname in hostnameOrIp auflösen */
		if(he == NULL)
		{
	   		return SOCKET_ERROR;
		}
		else
			memcpy(&amp;(addr-&gt;sin_addr),he-&gt;h_addr_list[0],4); /*die 4 Bytes der IP von he nach addr kopieren */
	}
    return 0;
}

void Thread1(PVOID pvoid)
{
	char format[10];
	char lool[100];
    recv(s1, format, sizeof(format), 0);  // FUnktioniert nicht 
	sprintf(lool, &quot;%d&quot;, WSAGetLastError()); // WSA error 10038
	MessageBox(0, lool, lool, 0);
	_endthread () ;
}
</code></pre>
<p>Socket operation on nonsocket.</p>
<p>An operation was attempted on something that is not a socket. Either the socket handle parameter did not reference a valid socket, or for select, a member of an fd_set was not valid.</p>
<p>was heißt das jetzt genau?<br />
Danke!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1598801</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1598801</guid><dc:creator><![CDATA[wasagetlasterror10038]]></dc:creator><pubDate>Tue, 14 Oct 2008 13:05:09 GMT</pubDate></item><item><title><![CDATA[Reply to Socket klappt nicht on Tue, 14 Oct 2008 13:09:22 GMT]]></title><description><![CDATA[<p>du müsstest schon die Addresse übergeben:</p>
<pre><code class="language-cpp">SOCKET connectSocket(SOCKET &amp;s, const char* szHostNameOrIp, int port);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1598806</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1598806</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Tue, 14 Oct 2008 13:09:22 GMT</pubDate></item><item><title><![CDATA[Reply to Socket klappt nicht on Tue, 14 Oct 2008 14:19:08 GMT]]></title><description><![CDATA[<p>Melan schrieb:</p>
<blockquote>
<p>du müsstest schon die Addresse übergeben:</p>
<pre><code class="language-cpp">SOCKET connectSocket(SOCKET &amp;s, const char* szHostNameOrIp, int port);
</code></pre>
</blockquote>
<p>wat?lol!</p>
<p>@threadersteller. GetLastError(). wir gucken hier doch nicht zeile für zeile deinen müll code durch. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_down"
      title=":-1:"
      alt="👎"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1598845</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1598845</guid><dc:creator><![CDATA[ascda]]></dc:creator><pubDate>Tue, 14 Oct 2008 14:19:08 GMT</pubDate></item><item><title><![CDATA[Reply to Socket klappt nicht on Tue, 14 Oct 2008 14:26:59 GMT]]></title><description><![CDATA[<p>ascda schrieb:</p>
<blockquote>
<p>Melan schrieb:</p>
<blockquote>
<p>du müsstest schon die Addresse übergeben:</p>
<pre><code class="language-cpp">SOCKET connectSocket(SOCKET &amp;s, const char* szHostNameOrIp, int port);
</code></pre>
</blockquote>
<p>wat?lol!</p>
<p>@threadersteller. GetLastError(). wir gucken hier doch nicht zeile für zeile deinen müll code durch. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_down"
      title=":-1:"
      alt="👎"
    /></p>
</blockquote>
<p>hat er doch... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f62e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_open_mouth"
      title=":open_mouth:"
      alt="😮"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1598850</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1598850</guid><dc:creator><![CDATA[gosha16]]></dc:creator><pubDate>Tue, 14 Oct 2008 14:26:59 GMT</pubDate></item><item><title><![CDATA[Reply to Socket klappt nicht on Tue, 14 Oct 2008 14:35:23 GMT]]></title><description><![CDATA[<p>danke Melan! habe das &amp; hinzugefügt und jetz funzt es <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/1598854</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1598854</guid><dc:creator><![CDATA[wasagetlasterror10038]]></dc:creator><pubDate>Tue, 14 Oct 2008 14:35:23 GMT</pubDate></item><item><title><![CDATA[Reply to Socket klappt nicht on Tue, 14 Oct 2008 14:47:03 GMT]]></title><description><![CDATA[<p>ascda schrieb:</p>
<blockquote>
<p>wat?lol!<br />
@threadersteller. GetLastError(). wir gucken hier doch nicht zeile für zeile deinen müll code durch. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_down"
      title=":-1:"
      alt="👎"
    /></p>
</blockquote>
<p>was bist du den für ein kiddi wtf erst lesen dann denken dann schreiben und nicht erst schreiben rofl</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1598861</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1598861</guid><dc:creator><![CDATA[LOL!]]></dc:creator><pubDate>Tue, 14 Oct 2008 14:47:03 GMT</pubDate></item><item><title><![CDATA[Reply to Socket klappt nicht on Tue, 14 Oct 2008 14:48:30 GMT]]></title><description><![CDATA[<p>ascda schrieb:</p>
<blockquote>
<p>wir gucken hier doch nicht zeile für zeile deinen müll code durch. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_down"
      title=":-1:"
      alt="👎"
    /></p>
</blockquote>
<p>und was fällt dir ein einfach nen code als müllcode zu bezeichenen den du nichtmal verstehst? alda falda</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1598862</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1598862</guid><dc:creator><![CDATA[ROFL!3]]></dc:creator><pubDate>Tue, 14 Oct 2008 14:48:30 GMT</pubDate></item><item><title><![CDATA[Reply to Socket klappt nicht on Tue, 14 Oct 2008 15:26:41 GMT]]></title><description><![CDATA[<p>lol was isn hier los. ich gucke mir den code gar nicht erst an, wenn ihn mir jemand so für die füße klatscht und sagt: mach mal. so nicht. das mache ich nicht. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_down"
      title=":-1:"
      alt="👎"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1598884</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1598884</guid><dc:creator><![CDATA[ascda]]></dc:creator><pubDate>Tue, 14 Oct 2008 15:26:41 GMT</pubDate></item><item><title><![CDATA[Reply to Socket klappt nicht on Tue, 14 Oct 2008 16:59:49 GMT]]></title><description><![CDATA[<p>@ascda rofler inf.stundet<br />
du arme Wurst</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1598927</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1598927</guid><dc:creator><![CDATA[.......]]></dc:creator><pubDate>Tue, 14 Oct 2008 16:59:49 GMT</pubDate></item></channel></rss>