<?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 Programmierung]]></title><description><![CDATA[<p>Hallo</p>
<p>mein Problem bezieht sich auf die Socket Programmierung und zwar habe ich für den Client folgenden Code geschrieben:</p>
<pre><code>[cpp]

SOCKET MySocket; char serverip[20]; 
sockaddr_in addr; 
WSADATA wsaData; 

if (WSAStartup(MAKEWORD(2,0),&amp;wsaData) != 0) 
{ 
MessageBox(0,&quot;WSA konnte nicht initialisiert werden&quot;,&quot;Fehler&quot;,MB_OK); 
return false; 
} 

hostent* dns = gethostbyname(&quot;FuhrparkServer&quot;); 
sprintf(serverip, &quot;%u.%u.%u.%u&quot;,(unsigned char) dns-&gt;h_addr_list[0][0], (unsigned char) dns-&gt;h_addr_list[0][1], (unsigned char) dns-&gt;h_addr_list[0][2], (unsigned char) dns-&gt;h_addr_list[0][3]); addr.sin_family = AF_INET; 

addr.sin_port = htons(110);
 addr.sin_addr.s_addr = inet_addr(serverip); 
MySocket = socket( AF_INET, SOCK_STREAM,0); 

if(MySocket == 0) 
{ 
MessageBox(0,&quot;Socket konnte nicht initalisiert werden&quot;,&quot;Fehler&quot;,MB_OK); 
return false; 
} 

if(connect(MySocket, (sockaddr *) &amp;addr, sizeof(addr)) == -1) 
{ 
MessageBox(0,&quot;Es konnte keine Verbindung aufgebaut werden&quot;,&quot;Fehler&quot;,MB_OK); return false;
 } 

return true; }[/cpp]
</code></pre>
<p>Den Code habe ich von einem anderen User aus einem anderen Forum. Habe dann von einer Internetseite die mir hier auch empfohlen wurde einen Server Code erstellt:</p>
<pre><code>[cpp]	SOCKET MySocket;
	char serverip[20];
	sockaddr_in addr;
	sockaddr_in remote_addr;
	WSADATA wsaData;
	int size;
	int remote_sock;

	if (WSAStartup(MAKEWORD(2,0),&amp;wsaData) != 0)
	{
		MessageBox(0,&quot;WSA konnte nicht initialisiert werden&quot;,&quot;Fehler&quot;,MB_OK);
		return false;
	}

	addr.sin_family = AF_INET;
	addr.sin_port = htons(110);
	addr.sin_addr.s_addr = INADDR_ANY;

	MySocket = socket( AF_INET, SOCK_STREAM,0);

	if(bind(MySocket, (sockaddr* ) &amp;addr, sizeof(addr)) == -1)
	{
		MessageBox(0,&quot;Socket konnte nicht initalisiert werden&quot;,&quot;Fehler&quot;,MB_OK);
			return false;
	}

	if(listen(MySocket,1) == -1)
	{
		MessageBox(0,&quot;Es konnte keine Verbindung aufgebaut werden&quot;,&quot;Fehler&quot;,MB_OK);
		return false;
	}

	fflush(stdout);

	size = sizeof(remote_addr); 
	remote_sock = accept(MySocket,(sockaddr* ) &amp;remote_addr, &amp;size);
	fflush(stdout);

	if(remote_sock &lt; 0)
	{
		_close(MySocket);
		MessageBox(0,&quot;Socket geschlossen&quot;,&quot;Hinweis&quot;,MB_OK);
		return false;
	}

	fflush(stdout);

	size = send (remote_sock,&quot;Wilkommen&quot;,11,0);

	if(size == -1)
	{
		MessageBox(0,&quot;Fehler&quot;,&quot;Fehler&quot;,MB_OK);
	}
	else
	{
		MessageBox(0,&quot;Gesendet&quot;,&quot;Hinweis&quot;,MB_OK);
	}

	_close(remote_sock);
	_close(MySocket);
	fflush(stdout);

	return true;

}[/cpp]
</code></pre>
<p>Wie ich aber erkennen musste funktiniert gar nichts. Der Compiler hift mir nicht mehr der sagt alles ok, ich weiss net was ich falsch mache . Hab ich irgendwelche Bugs im Code oder wieso funktioniert das alles nicht.<br />
Ich dachte das sich der Client verbindet und der Server ein Wilkommen zurück schickt aber nichts geht</p>
<p>Ich brauche dringend Hilfe</p>
<p>Gruß Silver</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/127878/socket-programmierung</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Jul 2026 17:14:50 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/127878.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 28 Nov 2005 13:14:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Socket Programmierung on Mon, 28 Nov 2005 13:14:14 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>mein Problem bezieht sich auf die Socket Programmierung und zwar habe ich für den Client folgenden Code geschrieben:</p>
<pre><code>[cpp]

SOCKET MySocket; char serverip[20]; 
sockaddr_in addr; 
WSADATA wsaData; 

if (WSAStartup(MAKEWORD(2,0),&amp;wsaData) != 0) 
{ 
MessageBox(0,&quot;WSA konnte nicht initialisiert werden&quot;,&quot;Fehler&quot;,MB_OK); 
return false; 
} 

hostent* dns = gethostbyname(&quot;FuhrparkServer&quot;); 
sprintf(serverip, &quot;%u.%u.%u.%u&quot;,(unsigned char) dns-&gt;h_addr_list[0][0], (unsigned char) dns-&gt;h_addr_list[0][1], (unsigned char) dns-&gt;h_addr_list[0][2], (unsigned char) dns-&gt;h_addr_list[0][3]); addr.sin_family = AF_INET; 

addr.sin_port = htons(110);
 addr.sin_addr.s_addr = inet_addr(serverip); 
MySocket = socket( AF_INET, SOCK_STREAM,0); 

if(MySocket == 0) 
{ 
MessageBox(0,&quot;Socket konnte nicht initalisiert werden&quot;,&quot;Fehler&quot;,MB_OK); 
return false; 
} 

if(connect(MySocket, (sockaddr *) &amp;addr, sizeof(addr)) == -1) 
{ 
MessageBox(0,&quot;Es konnte keine Verbindung aufgebaut werden&quot;,&quot;Fehler&quot;,MB_OK); return false;
 } 

return true; }[/cpp]
</code></pre>
<p>Den Code habe ich von einem anderen User aus einem anderen Forum. Habe dann von einer Internetseite die mir hier auch empfohlen wurde einen Server Code erstellt:</p>
<pre><code>[cpp]	SOCKET MySocket;
	char serverip[20];
	sockaddr_in addr;
	sockaddr_in remote_addr;
	WSADATA wsaData;
	int size;
	int remote_sock;

	if (WSAStartup(MAKEWORD(2,0),&amp;wsaData) != 0)
	{
		MessageBox(0,&quot;WSA konnte nicht initialisiert werden&quot;,&quot;Fehler&quot;,MB_OK);
		return false;
	}

	addr.sin_family = AF_INET;
	addr.sin_port = htons(110);
	addr.sin_addr.s_addr = INADDR_ANY;

	MySocket = socket( AF_INET, SOCK_STREAM,0);

	if(bind(MySocket, (sockaddr* ) &amp;addr, sizeof(addr)) == -1)
	{
		MessageBox(0,&quot;Socket konnte nicht initalisiert werden&quot;,&quot;Fehler&quot;,MB_OK);
			return false;
	}

	if(listen(MySocket,1) == -1)
	{
		MessageBox(0,&quot;Es konnte keine Verbindung aufgebaut werden&quot;,&quot;Fehler&quot;,MB_OK);
		return false;
	}

	fflush(stdout);

	size = sizeof(remote_addr); 
	remote_sock = accept(MySocket,(sockaddr* ) &amp;remote_addr, &amp;size);
	fflush(stdout);

	if(remote_sock &lt; 0)
	{
		_close(MySocket);
		MessageBox(0,&quot;Socket geschlossen&quot;,&quot;Hinweis&quot;,MB_OK);
		return false;
	}

	fflush(stdout);

	size = send (remote_sock,&quot;Wilkommen&quot;,11,0);

	if(size == -1)
	{
		MessageBox(0,&quot;Fehler&quot;,&quot;Fehler&quot;,MB_OK);
	}
	else
	{
		MessageBox(0,&quot;Gesendet&quot;,&quot;Hinweis&quot;,MB_OK);
	}

	_close(remote_sock);
	_close(MySocket);
	fflush(stdout);

	return true;

}[/cpp]
</code></pre>
<p>Wie ich aber erkennen musste funktiniert gar nichts. Der Compiler hift mir nicht mehr der sagt alles ok, ich weiss net was ich falsch mache . Hab ich irgendwelche Bugs im Code oder wieso funktioniert das alles nicht.<br />
Ich dachte das sich der Client verbindet und der Server ein Wilkommen zurück schickt aber nichts geht</p>
<p>Ich brauche dringend Hilfe</p>
<p>Gruß Silver</p>
]]></description><link>https://www.c-plusplus.net/forum/post/928955</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/928955</guid><dc:creator><![CDATA[Silvercreast]]></dc:creator><pubDate>Mon, 28 Nov 2005 13:14:14 GMT</pubDate></item><item><title><![CDATA[Reply to Socket Programmierung on Mon, 28 Nov 2005 15:54:25 GMT]]></title><description><![CDATA[<p>Da fehlt ja auch die Main() <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/929032</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/929032</guid><dc:creator><![CDATA[Panke]]></dc:creator><pubDate>Mon, 28 Nov 2005 15:54:25 GMT</pubDate></item><item><title><![CDATA[Reply to Socket Programmierung on Mon, 28 Nov 2005 17:08:36 GMT]]></title><description><![CDATA[<p>die hab ich net mit kopiert</p>
]]></description><link>https://www.c-plusplus.net/forum/post/929095</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/929095</guid><dc:creator><![CDATA[Silvercreast]]></dc:creator><pubDate>Mon, 28 Nov 2005 17:08:36 GMT</pubDate></item><item><title><![CDATA[Reply to Socket Programmierung on Mon, 28 Nov 2005 19:52:14 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile.php?mode=viewprofile&amp;u=403" rel="nofollow">HumeSikkins</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=15" rel="nofollow">C++</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum.php?f=4" rel="nofollow">WinAPI</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic.php?t=39405" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/929229</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/929229</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Mon, 28 Nov 2005 19:52:14 GMT</pubDate></item></channel></rss>