|Subject:||Re: indy sockets question (newbie).|
|Posted by:||Remy Lebeau (TeamB) (firstname.lastname@example.org)|
|Date:||Thu, 7 Apr 2005|
"jim" <gy…@vivodinet.gr> wrote in message
> Is there any way possible the the server can send
> data over the connection and the client reads it?
> Without the client sending something first...
Of course. Many protocols would not work otherwise. POP3 and SMPT, for
example, both have the server provide an initial greeting to the client
before the client does anything.
> I mean not inside the OnExecute method.
You can use the OnConnect event to send data to the client as soon as it
> let's say that i want to send a text from the server to
> the client on a ButtonClick event.
That, on the other hand, is a different issue, but still doable. Simply
call LockList() on the server's Threads property, locate the desired
TIdPeerThread pointer within the list, Write() to its Connection as desired,
then call UnlockList() to release the list.
> what modification is there to be done at the client's
> side in order to receive it.
Read from the socket periodically. Either in a timer or a worker thread.
> i tried using the OnWork event but nothing happens.
Nor should it, because that is not what that event is meant for. The
OnWork... events provide progress tracking while a read/write operation is
already being performed. They are not notifications that data is available
for reading. Indy has no such notifications to begin with. You have to
poll the socket periodically to detect incoming unsolicated data.
indy sockets question (newbie). posted by jim on Thu, 07 Apr 2005