On 11/10/11 2:23 PM, Mikael wrote:
I need my application to be a TCP server (almost), clients will
connect, send one message to the server,
receive an answer back and then the client will be silent, at specific
intervals the server should send a
message out to the client and get a response back, is this possible to
do ?
Yes. As soon as the client does not close the connection, and that the
connection is not closed by the system because it's inactive.
The first thing that crossed my mind would be to send out my message
in the sessionIdle() method,
and then the answer would come in as a normal request that I could
handle, but in this case there is
no response to send back to the client.
Use the sessionIdle() message on the server to periodically send a
message back to the client. Just count the number of sessionIdle event
you receive to be able to send the message when you want (ie, if it's
received every 30 seconds, and if you want to send a message to the
client every 5 minutes, then count 10 sessionIdle events before you send
a message to the client. You can store the counter in the session, as an
attribute).
That should work.
--
Regards,
Cordialement,
Emmanuel Lécharny
www.iktek.com