Re: multi-threaded server
- From: "William Stacey [C# MVP]" <william.stacey@xxxxxxxxx>
- Date: Thu, 5 Oct 2006 18:15:17 -0400
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
| >>> >
| >>>
| >>>
| >>
| >>
| >
| >
|
|
.
- References:
- multi-threaded server
- From: PaulH
- Re: multi-threaded server
- From: Alexander Nickolov
- Re: multi-threaded server
- From: m
- Re: multi-threaded server
- From: PaulH
- Re: multi-threaded server
- From: m
- Re: multi-threaded server
- From: Chris Becke
- Re: multi-threaded server
- From: Alexander Nickolov
- Re: multi-threaded server
- From: Arkady Frenkel
- multi-threaded server
- Prev by Date: Re: How to close a socket twice?
- Next by Date: Re: bad performance for recvfrom function.
- Previous by thread: Re: multi-threaded server
- Next by thread: Re: multi-threaded server
- Index(es):
Relevant Pages
|