<?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[Blocking Call Problem bzgl Socketprogrammierung]]></title><description><![CDATA[<p>Hi zusammen,</p>
<p>ich sitze seit heute morgen am selben Problem. Google und RTFM haben mir nicht geholfen.<br />
Ich möchte ein Programm schreiben das folgendes macht:<br />
(das essentielle davon ist schon realisiert und tut auch)</p>
<p>Es soll Texte übers LAN empfangen und senden (simpler Chat)<br />
Da send() und recv() stehen bleiben bis was passiert, habe ich nonblocking aktiviert.<br />
Allerdings tut das ganze in meiner Schleife(n) nicht und ich weiss nicht woran es liegt.<br />
Bin für jede Hilfe dankbar! Danke im Vorraus!<br />
Das Thema Threads bitte nicht ansprechen, ich möchte es erst zum laufen bringen und auch nicht mit select() oder sonstigem. <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>Codefragment:</p>
<pre><code class="language-cpp">acceptSocket = accept(mysocket,NULL,NULL);

if(acceptSocket &gt; 0)

{
cout &lt;&lt; &quot;Client connected&quot; &lt;&lt; endl;

u_long nonBlocking;
nonBlocking=1; // Mit 0 könnte man das später wieder rückgängig machen...
ioctlsocket(acceptSocket,FIONBIO,&amp;nonBlocking);

for(;;)
{

char incoming[256];

int rec=0;

rec = recv(acceptSocket, incoming, strlen(incoming),0);

while(rec!=0)
{
char welcome[256];
cout &lt;&lt; &quot;Type in message: &quot; &lt;&lt; endl;
cin.getline(welcome, strlen(welcome));
send(acceptSocket, welcome, strlen(welcome) + 1, NULL);
}

cout &lt;&lt; &quot;Incoming: &quot; &lt;&lt; incoming &lt;&lt; endl;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/118133/blocking-call-problem-bzgl-socketprogrammierung</link><generator>RSS for Node</generator><lastBuildDate>Sat, 04 Jul 2026 11:18:51 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/118133.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 15 Aug 2005 14:53:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Blocking Call Problem bzgl Socketprogrammierung on Mon, 15 Aug 2005 14:53:50 GMT]]></title><description><![CDATA[<p>Hi zusammen,</p>
<p>ich sitze seit heute morgen am selben Problem. Google und RTFM haben mir nicht geholfen.<br />
Ich möchte ein Programm schreiben das folgendes macht:<br />
(das essentielle davon ist schon realisiert und tut auch)</p>
<p>Es soll Texte übers LAN empfangen und senden (simpler Chat)<br />
Da send() und recv() stehen bleiben bis was passiert, habe ich nonblocking aktiviert.<br />
Allerdings tut das ganze in meiner Schleife(n) nicht und ich weiss nicht woran es liegt.<br />
Bin für jede Hilfe dankbar! Danke im Vorraus!<br />
Das Thema Threads bitte nicht ansprechen, ich möchte es erst zum laufen bringen und auch nicht mit select() oder sonstigem. <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>Codefragment:</p>
<pre><code class="language-cpp">acceptSocket = accept(mysocket,NULL,NULL);

if(acceptSocket &gt; 0)

{
cout &lt;&lt; &quot;Client connected&quot; &lt;&lt; endl;

u_long nonBlocking;
nonBlocking=1; // Mit 0 könnte man das später wieder rückgängig machen...
ioctlsocket(acceptSocket,FIONBIO,&amp;nonBlocking);

for(;;)
{

char incoming[256];

int rec=0;

rec = recv(acceptSocket, incoming, strlen(incoming),0);

while(rec!=0)
{
char welcome[256];
cout &lt;&lt; &quot;Type in message: &quot; &lt;&lt; endl;
cin.getline(welcome, strlen(welcome));
send(acceptSocket, welcome, strlen(welcome) + 1, NULL);
}

cout &lt;&lt; &quot;Incoming: &quot; &lt;&lt; incoming &lt;&lt; endl;

}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/852625</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/852625</guid><dc:creator><![CDATA[Vanatik]]></dc:creator><pubDate>Mon, 15 Aug 2005 14:53:50 GMT</pubDate></item><item><title><![CDATA[Reply to Blocking Call Problem bzgl Socketprogrammierung on Mon, 15 Aug 2005 15:02:30 GMT]]></title><description><![CDATA[<p>select() ist die Lösung.</p>
<p><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/winsock_functions.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/winsock_functions.asp</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/852634</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/852634</guid><dc:creator><![CDATA[select]]></dc:creator><pubDate>Mon, 15 Aug 2005 15:02:30 GMT</pubDate></item><item><title><![CDATA[Reply to Blocking Call Problem bzgl Socketprogrammierung on Mon, 15 Aug 2005 15:08:41 GMT]]></title><description><![CDATA[<p>select schrieb:</p>
<blockquote>
<p>select() ist die Lösung.</p>
<p><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/winsock_functions.asp" rel="nofollow">http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/winsock_functions.asp</a></p>
</blockquote>
<p>boah echt? threads auch <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /><br />
aber so muss es auch gehen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/852640</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/852640</guid><dc:creator><![CDATA[Vanatik]]></dc:creator><pubDate>Mon, 15 Aug 2005 15:08:41 GMT</pubDate></item><item><title><![CDATA[Reply to Blocking Call Problem bzgl Socketprogrammierung on Mon, 15 Aug 2005 15:09:25 GMT]]></title><description><![CDATA[<blockquote>
<p>Allerdings tut das ganze in meiner Schleife(n) nicht und ich weiss nicht woran es liegt.</p>
</blockquote>
<p>Tolle Fehlerbeschreibung. Und tolle Fehlerbehandlung in deinem Code.</p>
<p>Und die Bedingung der while-Schleife ist auch ziemlich komisch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/852642</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/852642</guid><dc:creator><![CDATA[select ist die Lösung]]></dc:creator><pubDate>Mon, 15 Aug 2005 15:09:25 GMT</pubDate></item><item><title><![CDATA[Reply to Blocking Call Problem bzgl Socketprogrammierung on Mon, 15 Aug 2005 15:14:20 GMT]]></title><description><![CDATA[<p>select ist die Lösung schrieb:</p>
<blockquote>
<blockquote>
<p>Allerdings tut das ganze in meiner Schleife(n) nicht und ich weiss nicht woran es liegt.</p>
</blockquote>
<p>Tolle Fehlerbeschreibung. Und tolle Fehlerbehandlung in deinem Code.</p>
<p>Und die Bedingung der while-Schleife ist auch ziemlich komisch.</p>
</blockquote>
<p>Das Errorhandling habe ich extra raus damit es übersichtlicher ist.</p>
<p>Das Programm soll foldendes tun: Daten empfangen und gleich ausgeben wenn welche empfangen wurden.<br />
Falls keine empfangen wurden soll man senden können.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/852650</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/852650</guid><dc:creator><![CDATA[Vanatik]]></dc:creator><pubDate>Mon, 15 Aug 2005 15:14:20 GMT</pubDate></item><item><title><![CDATA[Reply to Blocking Call Problem bzgl Socketprogrammierung on Mon, 22 Aug 2005 13:36:32 GMT]]></title><description><![CDATA[<p>Ich muss dich enttäuschen. Leider blockt recv bis Daten ankommen. Das Problem hab ich auch. Eine Lösung ist select(), die du aber nicht haben möchtest. Eine andere ist setsockopt(). Dort kann man das timeout für das Socket setzen. Aber so ganz toll ist das auch nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/856172</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/856172</guid><dc:creator><![CDATA[mein_name_ist_hase]]></dc:creator><pubDate>Mon, 22 Aug 2005 13:36:32 GMT</pubDate></item></channel></rss>