๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Send buffer from server to a client

#4487
From: Remy Lebeau (TeamB)
Date: Thu, 27 Jan 2005 19:05
41 lines
2697 bytes
"Vin๏ฟฝcius" <vgalo2000@yahoo.com.br> wrote in message
news:41f91ff2@newsgroups.borland.com...

> There is a IdTCPClient1->ReadBuffer(...), but I can't call this
> in some structure like execute on the server or an event that set
> when the buffer has something to read for the client.

Yes, you can.  You just have to set it up yourself first.  See my other
reply.

> I take a look at "onWork" event but I don't understand how to use it.

OnWork has nothing to do with what you are asking for.

> In TClientSocket there is an event "OnClientRead", where
> we can read buffers when its something to read.

Indy is not an event-driven library to begin with.  When you want data, you
simply read the socket, and the reading does not return until data actually
arrives.  If you do not know when data will arrive, then you have to move
the reading into its own thread so that the reading will block the thread
and not the rest of your code.  The alternative is to use a timer instead,
calling ReadFromStack() periodically with a small timeout, and then process
any available data when the InputBuffer->Size is greater than zero.

> This also exists, "AThread->Connection->WriteBuffer()", but only
> can be called inside the events of the server, or I wrong??

You are wrong.  You can call WriteBuffer() at any time from anywhere you
want.  All you need is a pointer to the Connection.  From outside the event
handlers, you can use the server's ActiveThreads property to gain access to
the Connections that are currently running.

> there no exists IdTCPServer->WriteBuffer()

TIdTCPServer hosts multiple connections.  You need to call WriteBuffer() on
the particular connection that you are actually interested in writing to.


Gambit
Technical Details
Message-ID: <41f93ad5$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <41f90c54@newsgroups.borland.com> <41f91223$1@newsgroups.borland.com> <41f91ff2@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,2b30b06ce9be7f64
X-Google-Attributes: gid11508e,public
X-Google-Language: ENGLISH,ASCII
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.internet.socket
References: <41f90c54@newsgroups.borland.com> <41f91223$1@newsgroups.borland.com> <41f91ff2@newsgroups.borland.com>
Subject: Re: Send buffer from server to a client
Date: Thu, 27 Jan 2005 11:05:24 -0800
Lines: 43
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: <41f93ad5$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1106852565 68.69.17.41 (27 Jan 2005 11:02:45 -0800)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail