Discussion:
Indy Examples sending messages between server and client
(too old to reply)
D-Fan
2008-07-08 06:26:30 UTC
Permalink
Are there any Indy examples using simple messages between a a server pc
and many client pcs. The server will be using an Indy tcp server
component and the clients will use either a tcp server or a non server
component. These components will either send simple text or record
structures. Initially I can focus on simple text.

The server needs to be able to send a message to the client at any time.
The message will just be a flag that will signal the client that a
message needs to be picked up from the server. Once this signal has
been received, the client will send a request to the server for any
waiting messages. This makes me think that the client PC needs to have
an Indy server component or perhaps a client component with a timer to
look for the flag that there is a message.

If there are any examples that make use of Indy in this type of process
I would certainly appreciate a link or any insight as to the best
approach to take in this endeavor.
Remy Lebeau (TeamB)
2008-07-08 20:20:05 UTC
Permalink
Post by D-Fan
Are there any Indy examples using simple messages between a
a server pc and many client pcs.
Numerous examples have been posted before. Go to http://www.deja.com and
search the newsgroup archives.
Post by D-Fan
The server will be using an Indy tcp server component and the
clients will use either a tcp server or a non server component.
It has to be a TCP client component. A TCP server cannot comunicate with
another TCP server.
Post by D-Fan
The server needs to be able to send a message to the client at any time.
That requires you to implement an asynchronous protocol in your
communication. Clients have to poll the connection periodically in order to
read unsolicited data packets. The packets themselves have to be formatted
in a way that a client can differentiate between a server-initiated command
and a reply to a client-initiated command.
Post by D-Fan
This makes me think that the client PC needs to have an Indy server
component
No. That is not how TCP works.
Post by D-Fan
or perhaps a client component with a timer
Yes, or a polling thread.


Gambit
D-Fan
2008-07-09 18:06:10 UTC
Permalink
Thats fair enough. I have a few questions about approach and would
appreciate your input.

When should I use a Tidtcpclient v/s a Tidcmdtcpclient?

Does it make sense to send a header message stating the size of the
actual message to the server and then have the server issue a waitfor a
response of that size. This will make sure that the server receives the
entire message. If the full message is not received the server can
flush its buffer and reset itself.
Post by Remy Lebeau (TeamB)
Post by D-Fan
Are there any Indy examples using simple messages between a
a server pc and many client pcs.
Numerous examples have been posted before. Go to http://www.deja.com and
search the newsgroup archives.
Post by D-Fan
The server will be using an Indy tcp server component and the
clients will use either a tcp server or a non server component.
It has to be a TCP client component. A TCP server cannot comunicate with
another TCP server.
Post by D-Fan
The server needs to be able to send a message to the client at any time.
That requires you to implement an asynchronous protocol in your
communication. Clients have to poll the connection periodically in order to
read unsolicited data packets. The packets themselves have to be formatted
in a way that a client can differentiate between a server-initiated command
and a reply to a client-initiated command.
Post by D-Fan
This makes me think that the client PC needs to have an Indy server
component
No. That is not how TCP works.
Post by D-Fan
or perhaps a client component with a timer
Yes, or a polling thread.
Gambit
Remy Lebeau (TeamB)
2008-07-09 19:44:32 UTC
Permalink
Post by D-Fan
Thats fair enough. I have a few questions about approach and would
appreciate your input.
When should I use a Tidtcpclient v/s a Tidcmdtcpclient?
TIdTCPClient is a general-purpose TCP client. Youcan pretty much do
anything with it.

TIdCmdTCPClient is designed to be used when the server sends unsolicited
commands to the client, but not when the client sends commands to the
server. Well, that's not entirely true. The client could send commands,
but it would have to use Write() instead of SendCmd(), and the replies would
have to be formatted in a way that the TIdCmdTCPClient's CommandHandlers
collection could recognize.
Post by D-Fan
Does it make sense to send a header message stating the size of
the actual message to the server and then have the server issue
a waitfor a response of that size.
That depends on the particular nature of your protocol. Some protocols do
exactly that, particularly binary-oriented ones. Some protocols don't,
especially text-oriented ones. Though, that is not to say that binary
protocols always require it, or that text protocols can't use it, mind you.


Gambit
D-Fan
2008-07-09 23:19:20 UTC
Permalink
Who can I call on when I take on my endeavor to create a messaging
engine for my application? I can't let it take me months to do what an
experienced person can do in a few hours. I am willing to pay when I
need this help. Also, I may want someone to check off the final coding
to ensure that it is right.
Post by Remy Lebeau (TeamB)
Post by D-Fan
Thats fair enough. I have a few questions about approach and would
appreciate your input.
When should I use a Tidtcpclient v/s a Tidcmdtcpclient?
TIdTCPClient is a general-purpose TCP client. Youcan pretty much do
anything with it.
TIdCmdTCPClient is designed to be used when the server sends unsolicited
commands to the client, but not when the client sends commands to the
server. Well, that's not entirely true. The client could send commands,
but it would have to use Write() instead of SendCmd(), and the replies would
have to be formatted in a way that the TIdCmdTCPClient's CommandHandlers
collection could recognize.
Post by D-Fan
Does it make sense to send a header message stating the size of
the actual message to the server and then have the server issue
a waitfor a response of that size.
That depends on the particular nature of your protocol. Some protocols do
exactly that, particularly binary-oriented ones. Some protocols don't,
especially text-oriented ones. Though, that is not to say that binary
protocols always require it, or that text protocols can't use it, mind you.
Gambit
D-Fan
2008-07-09 23:19:39 UTC
Permalink
Who can I call on when I take on my endeavor to create a messaging
engine for my application? I can't let it take me months to do what an
experienced person can do in a few hours. I am willing to pay when I
need this help. Also, I may want someone to check off the final coding
to ensure that it is right.
Post by Remy Lebeau (TeamB)
Post by D-Fan
Thats fair enough. I have a few questions about approach and would
appreciate your input.
When should I use a Tidtcpclient v/s a Tidcmdtcpclient?
TIdTCPClient is a general-purpose TCP client. Youcan pretty much do
anything with it.
TIdCmdTCPClient is designed to be used when the server sends unsolicited
commands to the client, but not when the client sends commands to the
server. Well, that's not entirely true. The client could send commands,
but it would have to use Write() instead of SendCmd(), and the replies would
have to be formatted in a way that the TIdCmdTCPClient's CommandHandlers
collection could recognize.
Post by D-Fan
Does it make sense to send a header message stating the size of
the actual message to the server and then have the server issue
a waitfor a response of that size.
That depends on the particular nature of your protocol. Some protocols do
exactly that, particularly binary-oriented ones. Some protocols don't,
especially text-oriented ones. Though, that is not to say that binary
protocols always require it, or that text protocols can't use it, mind you.
Gambit
Chad Z. Hower aka Kudzu
2008-07-10 12:18:51 UTC
Permalink
Who can I call on when I take on my endeavor to create a messaging engine
for my application? I can't let it take me months to do what an
experienced person can do in a few hours. I am willing to pay when I need
this help. Also, I may want someone to check off the final coding to
ensure that it is right.
You can try Indy Experts which is now Hadi Hariri for smaller tasks. For
larger tasks I'm sure there are plenty of Indy developers willing to take on
work.

Loading...