<?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[mehrere clients mit winsock]]></title><description><![CDATA[<pre><code class="language-cpp">int annehmen()
{

    FD_ZERO(&amp;fdSetRead);     
    FD_SET(acceptSocket,&amp;fdSetRead);
    for(u=0;u&lt;MAX_CLIENTS;u++)
    {
      if(clients[u]!=INVALID_SOCKET)
      {
        FD_SET(clients[u],&amp;fdSetRead);
      }
    }
    rc=select(0,&amp;fdSetRead,NULL,NULL,NULL);
    if(rc==SOCKET_ERROR)
            MessageBox(NULL,&quot;SOCKET_ERROR&quot;,&quot;&quot;,MB_OK);
    if(FD_ISSET(acceptSocket,&amp;fdSetRead)) {
    for(u=0;u&lt;MAX_CLIENTS;u++)
      {
        if(clients[u]==INVALID_SOCKET)
        {
          clients[u]=accept(acceptSocket,NULL,NULL);
          MessageBox(NULL,&quot;Neuen Client angenommen&quot;,&quot;&quot;,MB_OK);
          break;
        }
      }
      //einen freien platz für den neuen client suchen, und die verbingung annehmen

   }
    for(u=0;u&lt;MAX_CLIENTS;u++)
    {
      if(clients[u]==INVALID_SOCKET)
      {
        continue; // ungültiger socket, d.h. kein verbunder client an dieser position im array
      }
      if(FD_ISSET(clients[u],&amp;fdSetRead))
      {int x=0,c;
     long rc2;
     timeout.tv_sec=0; 
     timeout.tv_usec=0; 
     rc=select(0,&amp;fdSetRead,NULL,NULL,&amp;timeout);
     if(rc&gt;0) 
     {      PlaySound(&quot;sounds\\goonigugu.wav&quot;,NULL,SND_FILENAME|SND_ASYNC);

            if(FD_ISSET(clients[u],&amp;fdSetRead))
      {     rc2=recv(clients[u],buf3,1024,0); 
            if(rc2==0 || rc2==SOCKET_ERROR)
        {
          MessageBox(hwnd,&quot;Client hat die Verbindung geschlossen&quot;,&quot;&quot;,MB_OK);
          closesocket(clients[u]);    // socket schliessen         
          clients[u]=INVALID_SOCKET;  // seinen platz wieder freigeben
        }
        }
            if(sounds()==-1)
            {
            strncat(buf,buf3,rc2);
            SetWindowText(hedit1,buf);
            SendMessage( hedit1, WM_VSCROLL, SB_BOTTOM, 0 );
            }
      }
    }
}
}
</code></pre>
<p>was is daran falsch???? wenn ich mit nem client drauf geh passiert nix (programm hängt)</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/148223/mehrere-clients-mit-winsock</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Jul 2026 03:50:39 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/148223.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 24 May 2006 13:30:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to mehrere clients mit winsock on Wed, 24 May 2006 13:30:50 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">int annehmen()
{

    FD_ZERO(&amp;fdSetRead);     
    FD_SET(acceptSocket,&amp;fdSetRead);
    for(u=0;u&lt;MAX_CLIENTS;u++)
    {
      if(clients[u]!=INVALID_SOCKET)
      {
        FD_SET(clients[u],&amp;fdSetRead);
      }
    }
    rc=select(0,&amp;fdSetRead,NULL,NULL,NULL);
    if(rc==SOCKET_ERROR)
            MessageBox(NULL,&quot;SOCKET_ERROR&quot;,&quot;&quot;,MB_OK);
    if(FD_ISSET(acceptSocket,&amp;fdSetRead)) {
    for(u=0;u&lt;MAX_CLIENTS;u++)
      {
        if(clients[u]==INVALID_SOCKET)
        {
          clients[u]=accept(acceptSocket,NULL,NULL);
          MessageBox(NULL,&quot;Neuen Client angenommen&quot;,&quot;&quot;,MB_OK);
          break;
        }
      }
      //einen freien platz für den neuen client suchen, und die verbingung annehmen

   }
    for(u=0;u&lt;MAX_CLIENTS;u++)
    {
      if(clients[u]==INVALID_SOCKET)
      {
        continue; // ungültiger socket, d.h. kein verbunder client an dieser position im array
      }
      if(FD_ISSET(clients[u],&amp;fdSetRead))
      {int x=0,c;
     long rc2;
     timeout.tv_sec=0; 
     timeout.tv_usec=0; 
     rc=select(0,&amp;fdSetRead,NULL,NULL,&amp;timeout);
     if(rc&gt;0) 
     {      PlaySound(&quot;sounds\\goonigugu.wav&quot;,NULL,SND_FILENAME|SND_ASYNC);

            if(FD_ISSET(clients[u],&amp;fdSetRead))
      {     rc2=recv(clients[u],buf3,1024,0); 
            if(rc2==0 || rc2==SOCKET_ERROR)
        {
          MessageBox(hwnd,&quot;Client hat die Verbindung geschlossen&quot;,&quot;&quot;,MB_OK);
          closesocket(clients[u]);    // socket schliessen         
          clients[u]=INVALID_SOCKET;  // seinen platz wieder freigeben
        }
        }
            if(sounds()==-1)
            {
            strncat(buf,buf3,rc2);
            SetWindowText(hedit1,buf);
            SendMessage( hedit1, WM_VSCROLL, SB_BOTTOM, 0 );
            }
      }
    }
}
}
</code></pre>
<p>was is daran falsch???? wenn ich mit nem client drauf geh passiert nix (programm hängt)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1064271</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1064271</guid><dc:creator><![CDATA[der unnötige]]></dc:creator><pubDate>Wed, 24 May 2006 13:30:50 GMT</pubDate></item><item><title><![CDATA[Reply to mehrere clients mit winsock on Wed, 24 May 2006 21:33:58 GMT]]></title><description><![CDATA[<p>Bei deinem ersten select()-Aufruf übergibst du als letzten Parameter NULL, das steht für blockierende Operation. Könnte das die Ursache sein?</p>
<p>Rob'</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1064634</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1064634</guid><dc:creator><![CDATA[Rob&#x27;]]></dc:creator><pubDate>Wed, 24 May 2006 21:33:58 GMT</pubDate></item></channel></rss>