🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.internet.socket
Article #2263

Re: Event driven receive

#2263
From: SVC
Date: Wed, 12 Jul 2006 16:08
49 lines
2759 bytes
My socket is non-blocking though I have no idea of the server's socket mode
of operation.

Is it possible to use the  WSAAsyncSelect()  in a console application (i.e.,
no window handle available, my communication module is a thread running in
the background)?

S.



"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:44b424b9$1@newsgroups.borland.com...
>
> "SVC" <svchamlian@hotmail.com> wrote in message
> news:44b41065$1@newsgroups.borland.com...
>
> > The problem is the receiving! Every time I call recv(...), it
> > seems like the server (black box) is slowing down.
>
> Reading from a socket, especially if you do it often, should not be
slowing
> the server down at all.  On the other hand, if you are not reading very
> often, that could, especially if the server is using sockets in blocking
> mode on its end.
>
> > Is there a way to make solely the Receiving process event
> > driven without altering the whole program?
>
> You can use ioctlsocket() to put the socket into non-blocking mode.  But
> keep in mind that doing so will greatly alter the behavior of your code.
If
> your code is currently written to expect blocking operations, then you
will
> have to re-write it in order to handle the socket events.  Not only for
> reading but for writing as well.  You need to use WSAAsyncSelect() or
> WSAEventSelect() to receive the actual events, and the logic of your
socket
> management will be split up considerably because of the event handling.
> When reading, you will have to buffer all incoming data, if you are not
> already doing so, in order to ensure that you do not lose data between
> events.  When writing, if the socket becomes blocked, then you have to
wait
> for an event to be triggered before you can write more data again.
>
>
> Gambit
>
>
Technical Details
Message-ID: <44b51e08@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!news2.volia.net!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <44b41065$1@newsgroups.borland.com> <44b424b9$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,51bf75bfa952f51
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "SVC" <svchamlian@hotmail.com>
From: "SVC" <svchamlian@hotmail.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <44b41065$1@newsgroups.borland.com> <44b424b9$1@newsgroups.borland.com>
Subject: Re: Event driven receive
Date: Wed, 12 Jul 2006 12:08:49 -0400
Lines: 51
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
NNTP-Posting-Host: 207.35.47.71
Message-ID: <44b51e08@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1152720392 207.35.47.71 (12 Jul 2006 09:06:32 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!news2.volia.net!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail