🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #16020

Re: WSA????

#16020
From: Tharun Pillay
Date: Wed, 04 Jun 2003 11:28
51 lines
2979 bytes
Exactly. We've defined the protocol and everything. We just don't know when
to close the socket. It's all about timing. Here's how it goes:

Step 1:     (OnClientConnect) Accept incomming connection (non-blocking
socket)
Step 2:     (OnClientRead) Spawn a new thread to recieve data from WInsock
Buf
Step 3:     Process the packet or repeat step 2 until processing can be
preformed
            each time terminating the thread once packet processing is done.
Step 4:     Send the response once consolidated packet processing complete
Step 5:     Close the socket

The problem is step 5. In a non-threadblocking socket, calling
Socket->SendBuf or Socket->SendText is useless in determining the amount of
data that has actually been sent. All it will return is the number of bytes
it *can* send.

A solution (without converting to thread-blocking)is to find out the number
of bytes sent over the particular socket.

If you're curious as to why we are not using thread-blocking sockets it's
because they're memory innefficient. Assume we get 10000 connections. This
means that we have 10000 threads running on over n CPUs. And even if we run
an 8 CPU config, that still makes it 1250 threads per CPU. And it's
frightenningly expensive.

The way it's done now, a thread pool size can be set. Transactions get
queued for processing whenever that's possible.

Tharun.


"Hans Galema" <j.m.galema.dontusethis@maartens.nl> wrote in message
news:3eddbd08$1@newsgroups.borland.com...
> Tharun Pillay wrote:
>
> > Trouble is that we don't know when the *server* must close the
connection -
> > we are relying on a timout or the client terminating the connection -
which
> > is dodgy.
>
> If you design the protocol for communicating with the proxyserver you
could
> decide that the server closes the connection after having forwarded the
received
> data to the client.
>
> Hans.
>
Technical Details
Message-ID: <3eddd710@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3edc7a5c@newsgroups.borland.com> <3edc7f28@newsgroups.borland.com> <3edcb8aa@newsgroups.borland.com> <3edccfa2$1@newsgroups.borland.com> <3eddb43a@newsgroups.borland.com> <3eddbd08$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,30c81141f30ce678
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-06-04 04:27:50 PST
From: "Tharun Pillay" <tharun@webmail.co.za>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3edc7a5c@newsgroups.borland.com> <3edc7f28@newsgroups.borland.com> <3edcb8aa@newsgroups.borland.com> <3edccfa2$1@newsgroups.borland.com> <3eddb43a@newsgroups.borland.com> <3eddbd08$1@newsgroups.borland.com>
Subject: Re: WSA????
Date: Wed, 4 Jun 2003 13:28:29 +0200
Lines: 53
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 196.15.202.200
Message-ID: <3eddd710@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1054725904 196.15.202.200 (4 Jun 2003 04:25:04 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail