🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Event driven receive

#2258
From: Remy Lebeau (TeamB)
Date: Tue, 11 Jul 2006 22:22
29 lines
2333 bytes
"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: <44b424b9$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news4.google.com!news.glorb.com!tudelft.nl!txtfeed1.tudelft.nl!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <44b41065$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
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <44b41065$1@newsgroups.borland.com>
Subject: Re: Event driven receive
Date: Tue, 11 Jul 2006 15:22:38 -0700
Lines: 31
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 68.69.17.41
Message-ID: <44b424b9$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1152656569 68.69.17.41 (11 Jul 2006 15:22:49 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news4.google.com!news.glorb.com!tudelft.nl!txtfeed1.tudelft.nl!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail