<?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[SocketServer Chat -&amp;gt; Probleme]]></title><description><![CDATA[<p>Hallo, ich programmiere gerade einen Chat mit einem SocketServer und einem Client.<br />
Es funktioniert ansich ganz gut, ich kann eine verbindung aufbauen und mein client schickt einen text der dann angezeigt wird.<br />
Leider komme ich nicht dazu einen Text einzugeben.<br />
Ansich sollte er wenn ich nichts schicke if(chatclient-&gt;dataAvailable()) in die else Verzweigung. das macht er aber nicht, er geht ständig davon aus, dass ich Daten bereitstelle, was aber nicht geschieht.</p>
<p>Hier der Quellcode zum Server:</p>
<pre><code class="language-cpp">int main(void)
{
	string eingabe =&quot; &quot;;
	string ausgabe = &quot; &quot;;
	ServerSocket chatsrv(Port);
	cout&lt;&lt;&quot;Server started&quot;&lt;&lt;endl;

	while(true)
	{
		cout&lt;&lt;&quot;Waiting for connection&quot;&lt;&lt;endl;
		Socket *chatclient = chatsrv.accept();
		if(chatclient != NULL)
		{
			cout&lt;&lt;&quot;connection established&quot;&lt;&lt;endl;

		}
		while(eingabe != &quot;exit&quot; &amp;&amp; ausgabe != &quot;exit&quot;)
		{
			if(chatclient-&gt;dataAvailable())
			{
				ausgabe = chatclient-&gt;readLine();
				cout&lt;&lt;&quot;Partner &lt; &quot;&lt;&lt;ausgabe&lt;&lt;endl;
			}
			else
			{
				while (_kbhit())
				{
					getline(cin,eingabe);
					chatclient-&gt;write(eingabe + '\n');
				}
			}
		}
	}

}
</code></pre>
<p>Falls ServerSocket.h und Socket.h benötigt werden stelle ich diese auch noch zur verfügung</p>
<p>help plox&quot;!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/295878/socketserver-chat-gt-probleme</link><generator>RSS for Node</generator><lastBuildDate>Sat, 15 Aug 2026 06:42:57 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/295878.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 23 Nov 2011 15:12:57 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to SocketServer Chat -&amp;gt; Probleme on Wed, 23 Nov 2011 15:12:57 GMT]]></title><description><![CDATA[<p>Hallo, ich programmiere gerade einen Chat mit einem SocketServer und einem Client.<br />
Es funktioniert ansich ganz gut, ich kann eine verbindung aufbauen und mein client schickt einen text der dann angezeigt wird.<br />
Leider komme ich nicht dazu einen Text einzugeben.<br />
Ansich sollte er wenn ich nichts schicke if(chatclient-&gt;dataAvailable()) in die else Verzweigung. das macht er aber nicht, er geht ständig davon aus, dass ich Daten bereitstelle, was aber nicht geschieht.</p>
<p>Hier der Quellcode zum Server:</p>
<pre><code class="language-cpp">int main(void)
{
	string eingabe =&quot; &quot;;
	string ausgabe = &quot; &quot;;
	ServerSocket chatsrv(Port);
	cout&lt;&lt;&quot;Server started&quot;&lt;&lt;endl;

	while(true)
	{
		cout&lt;&lt;&quot;Waiting for connection&quot;&lt;&lt;endl;
		Socket *chatclient = chatsrv.accept();
		if(chatclient != NULL)
		{
			cout&lt;&lt;&quot;connection established&quot;&lt;&lt;endl;

		}
		while(eingabe != &quot;exit&quot; &amp;&amp; ausgabe != &quot;exit&quot;)
		{
			if(chatclient-&gt;dataAvailable())
			{
				ausgabe = chatclient-&gt;readLine();
				cout&lt;&lt;&quot;Partner &lt; &quot;&lt;&lt;ausgabe&lt;&lt;endl;
			}
			else
			{
				while (_kbhit())
				{
					getline(cin,eingabe);
					chatclient-&gt;write(eingabe + '\n');
				}
			}
		}
	}

}
</code></pre>
<p>Falls ServerSocket.h und Socket.h benötigt werden stelle ich diese auch noch zur verfügung</p>
<p>help plox&quot;!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2147872</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2147872</guid><dc:creator><![CDATA[SocketServer]]></dc:creator><pubDate>Wed, 23 Nov 2011 15:12:57 GMT</pubDate></item><item><title><![CDATA[Reply to SocketServer Chat -&amp;gt; Probleme on Wed, 23 Nov 2011 15:23:30 GMT]]></title><description><![CDATA[<p>Wenn das Problem offensichtlich bei dataAvailable() liegt, solltest du die Funktion auch posten.<br />
(Und nur als Information: _kbhit() gehört weder zum C noch zum C++ Standard, aber das weißt du wahrscheinlich.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2147877</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2147877</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Wed, 23 Nov 2011 15:23:30 GMT</pubDate></item><item><title><![CDATA[Reply to SocketServer Chat -&amp;gt; Probleme on Wed, 23 Nov 2011 15:26:08 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">*   (c) 2006 Michael Zimmer, HTS     
int Socket::dataAvailable()
{
  const int len = 1024;
  char b[len];
  return recv(socket, b, len, MSG_PEEK);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2147878</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2147878</guid><dc:creator><![CDATA[SocketServer1]]></dc:creator><pubDate>Wed, 23 Nov 2011 15:26:08 GMT</pubDate></item><item><title><![CDATA[Reply to SocketServer Chat -&amp;gt; Probleme on Wed, 23 Nov 2011 15:53:44 GMT]]></title><description><![CDATA[<p>Und wo prüfst du ob recv() überhaupt erfolg hat? Sonst probier doch mal select(), das scheint mir in dem Fall irgendwie sinnvoller..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2147885</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2147885</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Wed, 23 Nov 2011 15:53:44 GMT</pubDate></item><item><title><![CDATA[Reply to SocketServer Chat -&amp;gt; Probleme on Wed, 23 Nov 2011 16:10:34 GMT]]></title><description><![CDATA[<p>kannst du mir die Methode umschreiben ?<br />
Ich habe die nicht programmiert sondern ein Professor an der TU Darmstadt.</p>
<p>Ich bin auf einem techn. Gymnasium die Klassen wurden uns gegeben wir sollen damit arbeiten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2147895</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2147895</guid><dc:creator><![CDATA[SocketServer3]]></dc:creator><pubDate>Wed, 23 Nov 2011 16:10:34 GMT</pubDate></item><item><title><![CDATA[Reply to SocketServer Chat -&amp;gt; Probleme on Wed, 23 Nov 2011 16:28:18 GMT]]></title><description><![CDATA[<p>Hm.. dann poste doch noch bitte die beiden Header, dann kann ich das gleich testen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2147898</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2147898</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Wed, 23 Nov 2011 16:28:18 GMT</pubDate></item><item><title><![CDATA[Reply to SocketServer Chat -&amp;gt; Probleme on Wed, 23 Nov 2011 17:12:09 GMT]]></title><description><![CDATA[<p>ich poste einfach mal alles <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>
<p>ServerSocketH</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------
#ifndef ServerSocketH
#define ServerSocketH
//---------------------------------------------------------------------------
#include &quot;Socket.h&quot;

class ServerSocket
{
private:
  int    port;
  SOCKET serverSocket;
public:
  ServerSocket(int port);
  Socket* accept();
  void close();
};
#endif
</code></pre>
<p>SocketH</p>
<pre><code class="language-cpp">#ifndef SocketH
#define SocketH

#include &lt;string&gt;
#include &lt;winsock2.h&gt;
using namespace std;

class Socket
{
private:
  string  host;
  int     port;
  SOCKET  socket;
public:
  Socket(string host, int port);
  Socket(SOCKET socket);  // wird zur Socketerzeugung beim ServerSocket benoetigt
  bool connect();
  int  dataAvailable();
  void write(int b);
  void write(const char* b, int len);
  void write(string s);
  int  read();
  int  read(char* b, int len);
  string readLine();
  void close();
};
#endif
</code></pre>
<p>Serversocket.cpp</p>
<pre><code class="language-cpp">#include &quot;ServerSocket.h&quot;
#include &lt;iostream&gt;
//---------------------------------------------------------------------------
//#pragma package(smart_init)

ServerSocket::ServerSocket(int port)
{
  this-&gt;port = port;
  // WinSock-DLL einbinden
  WSADATA wsa;
  WSAStartup(MAKEWORD(2,0),&amp;wsa);
  // Server-Socket erzeugen
  this-&gt;serverSocket = ::socket(AF_INET, SOCK_STREAM, 0);
  if (this-&gt;serverSocket &lt;= 0) {
    cerr &lt;&lt; &quot;Error: Socket\n&quot;;
    return;
  }

  // Erzeuge die Socketadresse des Servers
  SOCKADDR_IN myAddr;
  memset( &amp;myAddr, 0, sizeof(SOCKADDR_IN));
  myAddr.sin_family = AF_INET;
  myAddr.sin_addr.s_addr = htonl(INADDR_ANY);
  myAddr.sin_port = htons((short)this-&gt;port);

  // Erzeuge die Bindung an die Serveradresse
  // (d.h. an einen bestimmten Port)
  if (bind(serverSocket, (SOCKADDR*)&amp;myAddr, sizeof(SOCKADDR_IN)) == -1) {
    closesocket(serverSocket);
    cerr &lt;&lt; &quot;Error: bind\n&quot;;
    return;
  }
  // Teile dem Socket mit, dass Verbindungswunsch
  // eines Clients entgegengenommen wird
  if (listen(serverSocket, 5) == -1) {
    closesocket(serverSocket);
    cerr &lt;&lt; &quot;Error: listen\n&quot;;
    return;
  }
}

Socket* ServerSocket::accept()
{
  // Bearbeite die Verbindungswunsch von Clients
  // Der Aufruf von accept() blockiert solange,
  // bis ein Client Verbindung aufnimmt
  SOCKADDR_IN remoteAddr;
  int len = sizeof(SOCKADDR_IN);
  SOCKET clientSocket = ::accept(serverSocket, (SOCKADDR*)&amp;remoteAddr, &amp;len);
  if (clientSocket &gt; 0) {
    return new Socket(clientSocket);
  }
  return NULL;
}

void ServerSocket::close()
{
  closesocket(serverSocket);
}
</code></pre>
<p>Socket.cpp</p>
<pre><code class="language-cpp">/******************************************************************************
 *                                                                            *
 *   Klasse Socket                                                            *
 *                                                                            *
 *   Klasse zur Datenübertragung über die Socket Schnittstelle,               *
 *                                                                            *
 *   (c) 2006 Michael Zimmer, HTS                                             *
 *                                                                            *
 *   Borland C++Builder 4.0                                                   *
 *                                                                            *
 ****V1.0**********************************************************************/

//---------------------------------------------------------------------------
#include &quot;Socket.h&quot;
//---------------------------------------------------------------------------

Socket::Socket(string host, int port)
{
  this-&gt;port = port;
  this-&gt;host = host;
  // WinSock-DLL einbinden
  WSADATA m_wsa;
  WSAStartup(MAKEWORD(2,0), &amp;m_wsa);
  // Socket erzeugen
  this-&gt;socket = ::socket(AF_INET, SOCK_STREAM, 0);
}

Socket::Socket(SOCKET socket)
{
   this-&gt;socket = socket;
}

bool Socket::connect()
{
  SOCKADDR_IN addr;
  memset( &amp;addr, 0, sizeof( SOCKADDR_IN ));

  addr.sin_family = AF_INET;
  addr.sin_port = htons((short)this-&gt;port);
  addr.sin_addr.s_addr = inet_addr(this-&gt;host.c_str());

  // Verbindung herstellen
  int rc = ::connect(socket, (SOCKADDR*) &amp;addr, sizeof( SOCKADDR ));

  return rc != SOCKET_ERROR;
}

int Socket::dataAvailable()
{
  const int len = 1024;
  char b[len];
  return recv(socket, b, len, MSG_PEEK);
}

void Socket::write(int b)
{
  char tmp[1];
  tmp[0] = (char)b;
  send(socket, tmp, 1, 0);
}

void Socket::write(const char*b, int len)
{
  send(socket, b, len, 0);
}

void Socket::write(string s)
{
  send(socket, s.c_str(), (int)s.length(), 0);
}

int Socket::read()
{
  char tmp[1];
  recv(socket, tmp, 1, 0);
  return tmp[0];
}

int Socket::read(char* b, int len)
{
  return recv(socket, b, len, 0);
}

string Socket::readLine()
{
  char buffIn[256];
  int pos = -1;
  do {
    pos++;
    recv(socket, buffIn+pos, 1, 0);
  } while (buffIn[pos] != '\n');
  buffIn[pos] = '\0';  // echo-String ist mit '\n' abgechlossen
  return string(buffIn);
}

void Socket::close()
{
  closesocket(socket);
}
</code></pre>
<p>main</p>
<pre><code class="language-cpp">#pragma comment(lib, &quot;ws2_32.lib&quot;)
#include &lt;iostream&gt;
#include &lt;conio.h&gt;
#include &lt;stdio.h&gt;
#include &lt;string&gt;
#include &quot;ServerSocket.h&quot;
using namespace std;

#define Port 55555

int main(void)
{
	string eingabe =&quot; &quot;;
	string ausgabe = &quot; &quot;;
	ServerSocket chatsrv(Port);
	cout&lt;&lt;&quot;Server started&quot;&lt;&lt;endl;

	while(1)
	{
		cout&lt;&lt;&quot;Waiting for connection&quot;&lt;&lt;endl;
		Socket *chatclient = chatsrv.accept();
		if(chatclient != NULL)
		{
			cout&lt;&lt;&quot;connection established&quot;&lt;&lt;endl;

		}
		while(1)
		{
			if(chatclient-&gt;dataAvailable())
			{
				ausgabe = chatclient-&gt;readLine();
				cout&lt;&lt;&quot;Partner &lt; &quot;&lt;&lt;ausgabe&lt;&lt;endl;

			}
			else
			{
				while (_kbhit())
				{
					getline(cin,eingabe);
					chatclient-&gt;write(eingabe + '\n');

			}
			}
		}
	}

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2147903</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2147903</guid><dc:creator><![CDATA[SocketServer3]]></dc:creator><pubDate>Wed, 23 Nov 2011 17:12:09 GMT</pubDate></item><item><title><![CDATA[Reply to SocketServer Chat -&amp;gt; Probleme on Wed, 23 Nov 2011 18:24:41 GMT]]></title><description><![CDATA[<p>Oh man, den Code hat dein Professor geschrieben? Ich werde immer weiter desillusioniert hier, hilf mir doch bitte jemand.</p>
<p>Ersetze in Socket.cpp die Funktion dataAvailable() durch</p>
<pre><code class="language-cpp">int Socket::dataAvailable()
{
  fd_set set;
  FD_ZERO(&amp;set);
  FD_SET(this-&gt;socket, &amp;set);
  timeval timeout;
  timeout.tv_sec = 0;
  timeout.tv_usec = 25;
  if (select(this-&gt;socket + 1, &amp;set, 0, 0, &amp;timeout) == -1)
    return 0; // error
  return FD_ISSET(this-&gt;socket, &amp;set);
}
</code></pre>
<p>Und in main.cpp Zeile 37 while durch if.</p>
<p>Das bleibt zwar <s>extrem hässlich</s> etwas unschön, aber es funktioniert und da dein Prof das ja so vorgegeben hat..</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2147924</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2147924</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Wed, 23 Nov 2011 18:24:41 GMT</pubDate></item><item><title><![CDATA[Reply to SocketServer Chat -&amp;gt; Probleme on Wed, 23 Nov 2011 21:01:23 GMT]]></title><description><![CDATA[<p>Hallo, vielen dank das hat nun wunderbar geklappt hab nun weiter gemacht und bekomme weitere fehler <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=":/"
      alt="😕"
    /><br />
Schon bei der Namensübergabe taucht ein unerwarteter Pufferfehler in dieser Zeile auf:<br />
&quot; buffIn[pos] = '\0'; // echo-String ist mit '\n' abgechlossen&quot;<br />
aus der Socket.cpp</p>
<p>hier der server:</p>
<pre><code class="language-cpp">int main(void)
{
	unsigned int Port;
	time_t t;
	string text = &quot;&quot;;
	string name_me = &quot;Me&quot;;
	string name_partner = &quot;Opposite&quot;;
	cout&lt;&lt;&quot;Enter Portnumber &quot;;
	cin&gt;&gt;Port;
	ServerSocket chatsrv(Port);
	cout&lt;&lt;&quot;Server started&quot;&lt;&lt;endl;

	while(1)
	{
		Sleep(1000);
		system(&quot;cls&quot;);
		cout&lt;&lt;&quot;Waiting for connection, listening on Port &quot;&lt;&lt;Port&lt;&lt;endl;
		Socket *chatclient = chatsrv.accept();
		if(chatclient != NULL)
		{
		cout&lt;&lt;&quot;connection established&quot;&lt;&lt;endl;
		Sleep(1000);
		system(&quot;cls&quot;);
		cout &lt;&lt; &quot;============================================================&quot;&lt;&lt;endl&lt;&lt;endl;
		cout &lt;&lt;        &quot;Socket Chat v1.0 - Please enter your name &gt;&quot;;
		cin&gt;&gt;name_me;
		cout &lt;&lt; endl;
		cout &lt;&lt; &quot;============================================================&quot;&lt;&lt;endl&lt;&lt;endl;
		chatclient-&gt;write(name_me + &quot;\n&quot;);
		if ( chatclient-&gt;dataAvailable() )
		{
		name_partner = chatclient-&gt;readLine();
		}
		}
		while(text != &quot;Exit&quot; &amp;&amp; text != &quot;exit&quot; &amp;&amp; text != &quot;EXIT&quot;)
		{
			if(chatclient-&gt;dataAvailable())
			{
				text= chatclient-&gt;readLine();
				time(&amp;t);
				cout &lt;&lt; ctime(&amp;t) &lt;&lt;name_partner&lt;&lt;&quot; &lt; &quot; &lt;&lt; text &lt;&lt; endl;

			}
			else
			{
				while (_kbhit())
				{
					time(&amp;t);
					cout &lt;&lt; ctime(&amp;t) &lt;&lt; name_me &lt;&lt; &quot; &gt; &quot;;
					getline(cin,text);
					if(text==&quot;Ring&quot; || text==&quot;ring&quot; || text==&quot;RING&quot;)
						{
							chatclient-&gt;write(&quot;Sie haben ein Ring erhalten!\a\a\a\a\a\a\a\a\n&quot;);
							cout&lt;&lt; name_me &lt;&lt; &quot; &gt;&quot;&lt;&lt;(&quot;Sie haben ein Ring gesendet!\a\a\a\a\a\a\a\a\n\n&quot;);
						}

						else
							{
							cout&lt;&lt;endl;
							chatclient-&gt;write(text + &quot;\n&quot;);
							}
			}
			}
		}
		delete chatclient;
	}
</code></pre>
<p>und hier der client</p>
<pre><code class="language-cpp">int main(void)
{
	cout&lt;&lt;&quot;Enter IPnumber &quot;;
	getline(cin,IP);
	cout&lt;&lt;endl&lt;&lt;&quot;Enter Portnumber &quot;;
	cin&gt;&gt;Port;

	Socket* CSocket = new Socket(IP, Port);

	if (! CSocket-&gt;connect()) {
		cout&lt;&lt; &quot;Error: Connection failed!&quot;&lt;&lt;endl;
		return 1;
	}
	else 
	{
		cout&lt;&lt;&quot;connection established&quot;&lt;&lt;endl;
		Sleep(1000);
		system(&quot;cls&quot;);
		cout &lt;&lt; &quot;============================================================&quot;&lt;&lt;endl&lt;&lt;endl;
		cout &lt;&lt;        &quot;Socket Chat v1.0 - Please enter your name &gt;&quot;;
		cin&gt;&gt;name_me;
		cout &lt;&lt; endl;
		cout &lt;&lt; &quot;============================================================&quot;&lt;&lt;endl&lt;&lt;endl;
		CSocket-&gt;write(name_me+&quot;\n&quot;);
		if ( CSocket-&gt;dataAvailable() )
		{
		name_partner = CSocket-&gt;readLine();
		}
		}
		while(text != &quot;Exit&quot; &amp;&amp; text != &quot;exit&quot; &amp;&amp; text != &quot;EXIT&quot;)
		{
			if(CSocket-&gt;dataAvailable())
			{
				text= CSocket-&gt;readLine();
				time(&amp;t);
				cout &lt;&lt; ctime(&amp;t) &lt;&lt;name_partner&lt;&lt;&quot; &lt; &quot; &lt;&lt; text &lt;&lt; endl;

			}
			else
			{
				while (_kbhit())
				{
					time(&amp;t);
					cout &lt;&lt; ctime(&amp;t) &lt;&lt; name_me &lt;&lt; &quot; &gt; &quot;;
					getline(cin,text);
					if(text==&quot;Ring&quot; || text==&quot;ring&quot; || text==&quot;RING&quot;)
						{
							CSocket-&gt;write(&quot;Sie haben ein Ring erhalten!\a\a\a\a\a\a\a\a\n&quot;);
							cout&lt;&lt; name_me &lt;&lt; &quot; &gt;&quot;&lt;&lt;(&quot;Sie haben ein Ring gesendet!\a\a\a\a\a\a\a\a\n\n&quot;);
						}

						else
							{
							cout&lt;&lt;endl;
							CSocket-&gt;write(text + &quot;\n&quot;);
							}
			}
			}

	CSocket-&gt;close();
	}

	return 0;
}
</code></pre>
<p>bitte helf mir</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2147990</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2147990</guid><dc:creator><![CDATA[SocketKraam]]></dc:creator><pubDate>Wed, 23 Nov 2011 21:01:23 GMT</pubDate></item><item><title><![CDATA[Reply to SocketServer Chat -&amp;gt; Probleme on Wed, 23 Nov 2011 21:26:34 GMT]]></title><description><![CDATA[<p>Wenn die Verbindung geschlossen wird failt recv() und die Schleife läuft immer weiter, bis irgendwo zufällig ein '\n' gefunden wird. An der Stelle hast du dann aber natürlich keine Zugriffsrechte mehr und beim Versuch eine '\0' rein zu schreiben crasht es dann. Aber mal ehrlich: Das ist alles so schrecklich, ich kann dir da kaum weiter helfen. Guck dir den Stil deines Profs bloß nicht ab. In Zeile 8 z.B. - schreib einfach nur &quot;Socket sock(Port, IP)&quot;, das new brauchst du so gut wie nie. Die Fehlerliste könnte man jetzt noch bis ins nächste Jahrhundert fortführen, aber lassen wir das. Wie gesagt, das gestellte Framework ist völlig unbrauchbar, damit kann man doch nicht arbeiten geschweige denn davon lernen.</p>
<p>PS: Richtig und einheitlich einrücken solltest du dir angewöhnen. Hast du keine IDE die das für dich erledigt bzw. dich dabei unterstützt? Visual Studio 2010 wäre z.B. gratis, oder Eclipse, oder Code::Blocks.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2147999</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2147999</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Wed, 23 Nov 2011 21:26:34 GMT</pubDate></item><item><title><![CDATA[Reply to SocketServer Chat -&amp;gt; Probleme on Wed, 23 Nov 2011 21:36:56 GMT]]></title><description><![CDATA[<p>das problem ist leider dass ich den chat mit diesem 'framework' programmieren muss, da ich sonst 0 Punkte für das Projekt bekomme <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=":/"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2148001</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2148001</guid><dc:creator><![CDATA[SocketServer4]]></dc:creator><pubDate>Wed, 23 Nov 2011 21:36:56 GMT</pubDate></item><item><title><![CDATA[Reply to SocketServer Chat -&amp;gt; Probleme on Wed, 23 Nov 2011 21:40:03 GMT]]></title><description><![CDATA[<p>Kannst du es nicht einfach komplett selbst schreiben?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2148002</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2148002</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Wed, 23 Nov 2011 21:40:03 GMT</pubDate></item><item><title><![CDATA[Reply to SocketServer Chat -&amp;gt; Probleme on Wed, 23 Nov 2011 21:49:24 GMT]]></title><description><![CDATA[<p>nein leider habe ich was diese &quot;tiefe&quot; angeht keine ahnung.<br />
(Bin ja auf einem Gymi und studiere noch nicht..)</p>
<p>also das mit dem \n ist so gedacht, dass ich eben jedesmal nach ein &quot;\n&quot; nachschicken muss:<br />
z.B chatclient-&gt;write(text + &quot;\n&quot;);</p>
<p>aber irgendwie gibt es eben dort ein fehler ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2148005</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2148005</guid><dc:creator><![CDATA[Dev]]></dc:creator><pubDate>Wed, 23 Nov 2011 21:49:24 GMT</pubDate></item><item><title><![CDATA[Reply to SocketServer Chat -&amp;gt; Probleme on Wed, 23 Nov 2011 21:54:26 GMT]]></title><description><![CDATA[<p>edit: das seltsame ist, der client funktioniert er kommt nicht in diesen pufferüberlauf nur der server, irgendwo muss doch da der wurm drin stecken</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2148007</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2148007</guid><dc:creator><![CDATA[SocketServer32]]></dc:creator><pubDate>Wed, 23 Nov 2011 21:54:26 GMT</pubDate></item><item><title><![CDATA[Reply to SocketServer Chat -&amp;gt; Probleme on Wed, 23 Nov 2011 22:09:12 GMT]]></title><description><![CDATA[<p>Dev schrieb:</p>
<blockquote>
<p>(Bin ja auf einem Gymi und studiere noch nicht..)</p>
</blockquote>
<p>Das hindert einen doch nicht daran ein bisschen mit Sockets zu spielen. <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>
<p>Ein Dirty-Hack-Fix wäre:</p>
<pre><code class="language-cpp">text = chatclient-&gt;readLine();
if (text.length() == 0)
  break;
</code></pre>
<p>Und bei read()</p>
<pre><code class="language-cpp">if (recv(socket, buffIn+pos, 1, 0) &lt;= 0)
  return &quot;&quot;;
</code></pre>
<p>Wie gesagt, das wird zwar irgendwann funktionieren, aber es bleibt einfach unglaublich hässlich. Wenn mein Lehrer mir das vorsetzen würde, würde ich streiken. (Oder gleich zum Gericht gehen, ich denke da kommt man mit Mobbing gut durch.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2148013</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2148013</guid><dc:creator><![CDATA[cooky451]]></dc:creator><pubDate>Wed, 23 Nov 2011 22:09:12 GMT</pubDate></item></channel></rss>