🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
5 messages
5 total messages Started by Darl Mon, 03 Apr 2006 12:58
IdUDPClient - OnRead Event
#2501
Author: Darl
Date: Mon, 03 Apr 2006 12:58
27 lines
1975 bytes
Hi All,

I have an Indy 9 client/server project.

On the Server i have IdTCPServer and IdUDPServer
On the Client i have IdTCPClient and IdUDPClient

on the client I used the UDPclient to locate the server via boradcast,
when i get a response from the servers' UDPServer I then use the Clients
TCPClient to connect to the TCPServer.

Everything was working great, now, am about to add some functions on
the server to enable me control the client ie asking the client to log off
the
current user on the client. I then discovered that UDPClient  dont have
OnRead event, and
TCPClient  does not have OnCommandHandler or OnExecute.

My Question:
How can I send data from UDPServer or TCPSever to UDPClient or TCPClient if
the client is not
waiting for it (ie no Read Method is pending); I perfer UDPClient so that I
can send the command using boradcast when all client is affected.

NB: I did change my UDPClient on the client App to UDPServer, so I can use
the OnRead event but the Client App became unperdictable as to connecting to
the Server
Re: IdUDPClient - OnRead Event
#2502
Author: Remy Lebeau (TeamB)
Date: Mon, 03 Apr 2006 17:21
14 lines
1400 bytes
"Darl" <Darl@nospam.com> wrote in message
news:44311b8a@newsgroups.borland.com...

> How can I send data from UDPServer or TCPSever to UDPClient
> or TCPClient if the client is not waiting for it

If you need to accept packets asynchronously on the client side, then you
have to use a separate thread or timer which continously reads.  Do note
that you can no longer use SendCmd() under this scenerio, though, since the
thread/timer will interfer with SendCmd()'s own reading.


Gambit
Re: IdUDPClient - OnRead Event
#2503
Author: Darl
Date: Tue, 04 Apr 2006 13:11
25 lines
1929 bytes
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:4431598b$2@newsgroups.borland.com...
>
> If you need to accept packets asynchronously on the client side, then you
> have to use a separate thread or timer which continously reads.  Do note
> that you can no longer use SendCmd() under this scenerio, though, since
the
> thread/timer will interfer with SendCmd()'s own reading.

Am not using SendCmd on the client side though I use commandhandler on the
server side,
my client send request to the server using WritenLn() and ReadLn.

So will using any Thread/Timer interfer with the WriteLn()/ReadLn()  - I
doubt.
Can you just give a simple code so I can undersatnd better.

How about having two TIdTCPClient on the client, while I use one to send
Request to the Server the Other is in a Thread with constant ReadLn() loop.
and if possible to have one TCPClient bimd to two different port? cand I
read on one port and write on the Other port asynchronously.

Thanks
Darl.
Re: IdUDPClient - OnRead Event
#2504
Author: Remy Lebeau (TeamB)
Date: Tue, 04 Apr 2006 17:35
33 lines
1965 bytes
"Darl" <Darl@nospam.com> wrote in message
news:44326ff8@newsgroups.borland.com...

> Am not using SendCmd on the client side though I use commandhandler
> on the server side, my client send request to the server using WritenLn()
and ReadLn.

Then simply move the ReadLn() to a separate thread or timer.

> Can you just give a simple code so I can undersatnd better.

Look at the source code for TIdTelnet.  It is a threaded reader, since
telnet data is asynchronous.

> How about having two TIdTCPClient on the client, while I use one
> to send Request to the Server the Other is in a Thread with constant
> ReadLn() loop.

You do not need to use two sockets for that, and that is wasted resources
anyway.

> if possible to have one TCPClient bimd to two different port?

That is not possible.

> cand I read on one port and write on the Other port asynchronously.

You do not need two sockets for that.  You can have one thread writing to 1
socket while another thread reads from the same socket.


Gambit
Re: IdUDPClient - OnRead Event
#2509
Author: Remy Lebeau (TeamB)
Date: Thu, 06 Apr 2006 17:57
13 lines
1429 bytes
"Darl" <Darl@nospam.com> wrote in message
news:443548bf@newsgroups.borland.com...

> The problem is that TIdTelnet is writen in Pascal which I
> don't understand. I still ask if you can just give a little code
> with respect to asynchronous

Go to http://www.deja.com and search through the newsgroup archives.  Sample
code has already been posted several time before.


Gambit
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads