Re: multi-threaded server



IIRC, internally it uses WaitForMultipleObjects to wait on socket handles
and current max is 64 handles. I assume 64 was some arbitrary number they
picked way back when.

--
William Stacey [C# MVP]

"Arkady Frenkel" <arkadyf@xxxxxxxxxxxxxxxx> wrote in message
news:e6FtNuE6GHA.3644@xxxxxxxxxxxxxxxxxxxxxxx
| The problem of select() in windows that it implemented using WFMO which
| support max of 64 handles, so select() support max of 64 winsock handles
| Arkady
|
| "Alexander Nickolov" <agnickolov@xxxxxxxx> wrote in message
| news:%23CJOu%23$5GHA.4616@xxxxxxxxxxxxxxxxxxxxxxx
| > No, that's only a Windows limitation. You can define the
| > maximum number of sockets per select, but you'll need to
| > recompile your kernel. I think we've experimented with
| > up to 256K socket limit, but we don't actually use select.
| > On Linux 2.6 there's epoll(). FreeBSD has kqueue().
| > I'm not familuar with System V, may be only poll() and
| > select(). The problem with select() is it transmits all socket
| > bits in both directions, which becomes quite a bit of data
| > with tens of thousands of sockets... It'd be completely
| > unmanageable in Windows where you have 4 bytes
| > per socket instead of 1 bit. Thus the 64 sockets hard
| > limitation of select() in WinSock.
| >
| > --
| > =====================================
| > Alexander Nickolov
| > Microsoft MVP [VC], MCSD
| > email: agnickolov@xxxxxxxx
| > MVP VC FAQ: http://www.mvps.org/vcfaq
| > =====================================
| >
| > "Chris Becke" <chris.becke@xxxxxxxxx> wrote in message
| > news:eTRU9g85GHA.1200@xxxxxxxxxxxxxxxxxxxxxxx
| >> select only scales up to 64 sockets though doesnt it?
| >>
| >> Is there a practical way to handle 1000 connections in a *nix
compatible
| >> way? Is that many connections even practical for IOCP?
| >>
| >> "m" <m@xxx> wrote in message
| >> news:OeOCEq75GHA.4604@xxxxxxxxxxxxxxxxxxxxxxx
| >>> Yes - typically with select etc.
| >>>
| >>> "PaulH" <paul.heil@xxxxxxxxx> wrote in message
| >>> news:1159968773.282515.231130@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| >>> >
| >>> > m wrote:
| >>> >> BTW: the most scaleable option on Windows is IOCP - the only
| >> disadvatage
| >>> >> is
| >>> >> hard portability to *NIX.
| >>> >>
| >>> >> "Alexander Nickolov" <agnickolov@xxxxxxxx> wrote in message
| >>> >> news:O0SZjo05GHA.3920@xxxxxxxxxxxxxxxxxxxxxxx
| >>> >> > Use non-blocking sockets. Blocking sockets don't scale
| >>> >> > because they require dedicated threads. The server dies
| >>> >> > under the weight of the sheer number of its own threads...
| >>> >> >
| >>> >> > --
| >>> >> > =====================================
| >>> >> > Alexander Nickolov
| >>> >> > Microsoft MVP [VC], MCSD
| >>> >> > email: agnickolov@xxxxxxxx
| >>> >> > MVP VC FAQ: http://www.mvps.org/vcfaq
| >>> >> > =====================================
| >>> >> >
| >>> >> > "PaulH" <paul.heil@xxxxxxxxx> wrote in message
| >>> >> > news:1159913152.352073.320070@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
| >>> >> >> Is it enough to kick-off a new thread when the accept() call
| >> succeeds
| >>> >> >> as below, or do I need to do something more substantial to have
a
| >>> >> >> server that can handle multiple clients on a single port?
| >>> >> >>
| >>> >> >> Server()
| >>> >> >> {
| >>> >> >> /*... init*/
| >>> >> >> while (TRUE)
| >>> >> >> {
| >>> >> >> SOCKET client = accept(...);
| >>> >> >> if (client != INVALID_SOCKET)
| >>> >> >> {
| >>> >> >> CreateThread(NULL, 0, ServerThread, client, 0, NULL);
| >>> >> >> }
| >>> >> >> }
| >>> >> >> /*... cleanup*/
| >>> >> >> }
| >>> >> >>
| >>> >> >> static DWORD __stdcall ServerThread(SOCKET client)
| >>> >> >> {
| >>> >> >> char buffer[1024] = {0};
| >>> >> >> int nRecv = 0;
| >>> >> >> do
| >>> >> >> {
| >>> >> >> nRecv = recv(client, buffer, sizeof(buffer), 0);
| >>> >> >> /*...*/
| >>> >> >> } while (nRecv > 0)
| >>> >> >> }
| >>> >> >>
| >>> >> >>
| >>> >> >> Thanks,
| >>> >> >> PaulH
| >>> >> >>
| >>> >> >
| >>> >> >
| >>> >
| >>> > If multi-threading blocking calls is too 'heavy', what is used in
| >>> > *NIX,
| >>> > then? non-blocking?
| >>> >
| >>> > -PaulH
| >>> >
| >>>
| >>>
| >>
| >>
| >
| >
|
|


.



Relevant Pages

  • Re: Socket.Disconnect Method
    ... Although the exception list in the MSDN documentation ... Windows XP SP2. ... An error occurred when attempting to access the socket. ... use the SocketException.ErrorCode property to obtain the specific error code. ...
    (microsoft.public.vsnet.general)
  • Re: Socket.Disconnect Method
    ... method that only worked on platforms prior to Windows ... method is supported on Windows 2000 and Windows 98, ... An error occurred when attempting to access the socket. ... It looks to me like the underlying error code could have been: ...
    (microsoft.public.vsnet.general)
  • Re: Tcp Socket Close Event
    ... Shutdown | TcpClient Members | Managed Extensions for C++ ... Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows ... SocketExceptionAn error occurred when accessing the socket. ... associated with the TcpClient. ...
    (microsoft.public.dotnet.languages.vb)
  • RE: Best design pattern for a TCP "HUB" service
    ... For the maximum socket a TCPLister can accept, in theory it is 2^32-1, we ... In Socket programming, we have another term named backlog, which means the ... Use the Start method to begin listening for incoming connection requests. ... Windows Sockets server applications generally create a socket and then use ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Okay to create a socket PRIOR to ip configuration?
    ... > Microsoft MVP, MCSD ... >>I am experiencing some intermittent problems with winsock. ... >> windows systems should be communicating over winsock. ... >> socket has already been created. ...
    (microsoft.public.win32.programmer.networks)

Quantcast