Discussion:
Indy Server -> client
(too old to reply)
Thomas Mueller
2007-02-28 20:33:35 UTC
Permalink
Hi,

I am trying to use the Indy components (version 10) in a way that they
apparently were not meant for:

I have got a server app that can accept connections from multiple clients.
But in contrast to the normal way of the clients sending a request and the
server answering it, it want the server to keep the connections and send
requests to the clients to which they may or may not answer.

client ----connects to-------> server
client <---receives command--- server
client ----answers-----------> server

I hope you get what I mean. Everything in Indy seems to be geared toward
making this impossible. Can anybody point me in the right direction? An
example would be very helpful.

MfG
twm
Liz
2007-02-28 21:16:35 UTC
Permalink
Post by Thomas Mueller
I have got a server app that can accept connections from multiple
clients. But in contrast to the normal way of the clients sending a
request and the server answering it, it want the server to keep the
connections and send requests to the clients to which they may or may
not answer.
client ----connects to-------> server
client <---receives command--- server
client ----answers-----------> server
I hope you get what I mean. Everything in Indy seems to be geared
toward making this impossible. Can anybody point me in the right
direction? An example would be very helpful.
a bunch of the indy commands in some way or other do what you're
asking, but Im guessing you and your app arent thinking the same way IP
does, even the default wsocket could do it, but you'd have to write
your own language layout.

You could use irc but it is designed specifically round irc, although
the code behind it would show you exacly how to implement what you
wanted

All you need to do is have some syntax such as

nnnn [opt [opt [opt..]]] data

and then you could easily work through using whole lines

you sound like you've tried plenty of things, why dont you show the
nearest one you got to working and maybe we can point you in the right
direction
--
Liz the Brit
Delphi things I have released: http://www.xcalibur.co.uk/DelphiThings
Remy Lebeau (TeamB)
2007-02-28 21:59:02 UTC
Permalink
Post by Thomas Mueller
I am trying to use the Indy components (version 10) in a way
Since you have not described what you are actually doing with them,
there is no way to know if you are using them correctly or not.
Post by Thomas Mueller
I have got a server app that can accept connections from multiple
clients. But in contrast to the normal way of the clients sending a
request and the server answering it, it want the server to keep the
connections and send requests to the clients to which they may or
may not answer.
That is perfectly fine to do, and Indy supports that model. There is
nothing in the TCP spec that says data has to flow from the client to
the server initially. TCP is bi-directional. Either party can write
to the socket at any time.
Post by Thomas Mueller
client ----connects to-------> server
client <---receives command--- server
client ----answers-----------> server
Simply write your command to the client in the server's OnConnect or
OnExecute event, and then read the reply back immediately.
Post by Thomas Mueller
I hope you get what I mean. Everything in Indy seems to be geared
toward making this impossible.
That is not true, not even close. What you are asking for is very
easy to do with Indy.


Gambit
Richard Gillingham
2007-03-01 12:09:41 UTC
Permalink
Hi Thomas

You could use the messaging components in kbmMW
(www.components4developers.com) to do this. It supports a sophisticated
publish/subscribe mechanism as well as TCP or UDP transports.

Richard
Post by Thomas Mueller
Hi,
I am trying to use the Indy components (version 10) in a way that they
I have got a server app that can accept connections from multiple clients.
But in contrast to the normal way of the clients sending a request and the
server answering it, it want the server to keep the connections and send
requests to the clients to which they may or may not answer.
client ----connects to-------> server
client <---receives command--- server
client ----answers-----------> server
I hope you get what I mean. Everything in Indy seems to be geared toward
making this impossible. Can anybody point me in the right direction? An
example would be very helpful.
MfG
twm
Thomas Mueller
2007-03-01 19:55:42 UTC
Permalink
Hi,

Thanks for your answers, but I guess I wasn't clear enough about what I want
to do:

I want the client to connect to the server and keep that connection open for
each of them to send messages (short strings) at any time. On both sides,
receiving a message should trigger an event, which might but not
necessarily must result in an answer to be sent.

Or to rephrase: I want asynchronous communication between the two.

It's a little bit like a peer to peer chat application without an
intermediate server (so not like irc which requires a server to which both
clients connect, but more like the old Windows chat tool (whatever it was
called), where one of the participants acts as the server.)

All Indy examples seem to work on the assumption that a server only answers
to requests and a client sends a request to the server and waits for an
answer. It would help me a lot if somebody could give me an example on how
to write to the client side of a connection without waiting for an answer.
I couldn't figure it out myself.

I have written some socket based communication code years ago (see
http://www.dummzeuch.de/twmtcpip/english.html if you are interested) which
I could probably adapt but I hoped that I could avoid most of the low level
stuff by using Indy.

MfG
twm
Remy Lebeau (TeamB)
2007-03-01 20:17:30 UTC
Permalink
Post by Thomas Mueller
Thanks for your answers, but I guess I wasn't clear enough about
Yes, you were. Did you see my earlier reply?
Post by Thomas Mueller
I want the client to connect to the server and keep that connection
open
Post by Thomas Mueller
for each of them to send messages (short strings) at any time. On
both
Post by Thomas Mueller
sides, receiving a message should trigger an event, which might but
not
Post by Thomas Mueller
necessarily must result in an answer to be sent.
Or to rephrase: I want asynchronous communication between the two.
On the server side, simply do your reading in the OnExecute event, let
it block until data arrives, and then process what is received.

On the client side, you need to perform your reading in a separate
thread. Indy clients (other than TIdIRC and TIdTelnet) do not have
any asynchronous events, as Indy is not an asynchronous library to
begin with.
Post by Thomas Mueller
All Indy examples seem to work on the assumption that a server only
answers to requests and a client sends a request to the server and
waits
Post by Thomas Mueller
for an answer.
Indy is not limited to that. As I said in my earlier reply, what you
are asking for is very easy to implement with Indy.
Post by Thomas Mueller
It would help me a lot if somebody could give me an example on how
to write to the client side of a connection without waiting for an answer.
You should already know how, because it is the same as on the client
side. The server has a TIdTCPConnection object available for each
connected client. You read/write on the server side the same way you
do on the client side. The methods are the same. The only difference
is where you call them from.


Gambit
Liz
2007-03-01 20:31:54 UTC
Permalink
Post by Thomas Mueller
All Indy examples seem to work on the assumption that a server only
answers to requests and a client sends a request to the server and
waits for an answer. It would help me a lot if somebody could give me
an example on how to write to the client side of a connection without
waiting for an answer. I couldn't figure it out myself.
So not true

once they have connected neither has to do anything
The client can send the request, so could the server..

thats entirely up to you
--
Liz the Brit
Delphi things I have released: http://www.xcalibur.co.uk/DelphiThings
Kim Madsen
2007-03-01 21:23:49 UTC
Permalink
Hi,

Check this whitepaper:

http://www.components4programmers.com/downloads/kbmmw/documentation/The_WIB.PDF

If you have heard about a (very expensive) product called TIB from TIBCO,
then you will find
the same functionality (and more) in The WIB from Components4Developers.

It does all you are asking for and much more in a abstracted and
standardized way.
--
best regards
Kim Madsen
***@components4developers.com
www.components4developers.com

The best components for the best developers
Application server enabling technology for developers
Post by Thomas Mueller
Hi,
Thanks for your answers, but I guess I wasn't clear enough about what I want
I want the client to connect to the server and keep that connection open for
each of them to send messages (short strings) at any time. On both sides,
receiving a message should trigger an event, which might but not
necessarily must result in an answer to be sent.
Or to rephrase: I want asynchronous communication between the two.
It's a little bit like a peer to peer chat application without an
intermediate server (so not like irc which requires a server to which both
clients connect, but more like the old Windows chat tool (whatever it was
called), where one of the participants acts as the server.)
All Indy examples seem to work on the assumption that a server only answers
to requests and a client sends a request to the server and waits for an
answer. It would help me a lot if somebody could give me an example on how
to write to the client side of a connection without waiting for an answer.
I couldn't figure it out myself.
I have written some socket based communication code years ago (see
http://www.dummzeuch.de/twmtcpip/english.html if you are interested) which
I could probably adapt but I hoped that I could avoid most of the low level
stuff by using Indy.
MfG
twm
Loading...