Article View: borland.public.cppbuilder.internet.socket
Article #1954Re: Event driven receive
From: Robert
Date: Mon, 18 Sep 2006 19:48
Date: Mon, 18 Sep 2006 19:48
56 lines
3148 bytes
3148 bytes
"SVC" <svchamlian@hotmail.com> schrieb im Newsbeitrag news:44b51e08@newsgroups.borland.com... > 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:
<eemsvg$f1s$1@online.de>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!news.online.de!not-for-mailReferences:
<44b41065$1@newsgroups.borland.com> <44b424b9$1@newsgroups.borland.com> <44b51e08@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 Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!news.online.de!not-for-mail From: "Robert" <rjl@home.com> Newsgroups: borland.public.cppbuilder.internet.socket Subject: Re: Event driven receive Date: Mon, 18 Sep 2006 21:48:04 +0200 Organization: 1&1 Internet AG Lines: 58 Message-ID: <eemsvg$f1s$1@online.de> References: <44b41065$1@newsgroups.borland.com> <44b424b9$1@newsgroups.borland.com> <44b51e08@newsgroups.borland.com> NNTP-Posting-Host: pd957b51e.dip0.t-ipconnect.de X-Trace: online.de 1158608688 15420 217.87.181.30 (18 Sep 2006 19:44:48 GMT) X-Complaints-To: abuse@einsundeins.com NNTP-Posting-Date: Mon, 18 Sep 2006 19:44:48 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2869 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962 X-RFC2646: Format=Flowed; Original