I agree with Nathan's comment.
Come up with an agreed upon keep-alive sequence they can send periodically to check if the socket is still returning data.
Perhaps something like: @@NOOP and return OK if connection still alive.
Regards,
Richard Schoen | Director of Document Management Technologies, HelpSystems
T: + 1 952-486-6802
RJS Software Systems | A Division of HelpSystems
richard.schoen@xxxxxxxxxxxxxxx
www.rjssoftware.com
Visit me on: Twitter | LinkedIn
------------------------------
message: 2
date: Fri, 28 Aug 2015 16:35:46 -0400
from: Jeff Young <jyoung0950@xxxxxxxxx>
subject: keepalive in socket server program
I am working on a socket server program where the connection will remain open most of the day. The specifications from the client (I have no control over this) indicate that they will periodically send a keepalive to me.
My questions are: 1 - How do I detect that a keepalive was sent
2 - What (if anything) do I need to send back.
TIA
Jeff Young
Sr. Programmer Analyst
------------------------------
message: 3
date: Fri, 28 Aug 2015 14:06:04 -0700
from: Alan Campin <alan0307d@xxxxxxxxx>
subject: Re: keepalive in socket server program
My answer is that TCP will do that automatically and unless they are sending you are specific message you should have to do nothing but Scott could answer that question better than me. Unless one side or the other closes the connection or there is an error it stays open which goes to your earlier question about receive timeouts.
What I read from your answer is that this is not a traditional socket server/socket worker type of application. You are just going to accept the connection and stay in the server. You only have one connection? When the customer breaks the connection, you go back to waiting on an accept for another connection request.
On Fri, Aug 28, 2015 at 1:35 PM, Jeff Young <jyoung0950@xxxxxxxxx> wrote:
I am working on a socket server program where the connection will
remain open most of the day. The specifications from the client (I
have no control over this) indicate that they will periodically send a
keepalive to me.
My questions are: 1 - How do I detect that a keepalive was sent
2 - What (if anything) do I need to send back.
TIA
Jeff Young
Sr. Programmer Analyst
--
This is the RPG programming on the IBM i (AS/400 and iSeries)
(RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/rpg400-l.
------------------------------
message: 4
date: Fri, 28 Aug 2015 15:18:42 -0600
from: Nathan Andelin <nandelin@xxxxxxxxx>
subject: Re: keepalive in socket server program
1 - How do I detect that a keepalive was sent
2 - What (if anything) do I need to send back.
It is generally good practice for servers to drop client connections after periods of inactivity. But is sounds like your client wants the server to support a "keepalive" request to override a default drop due to inactivity.
Don't think of "keepalive" as any "standard" character or string to look for in the input buffer. Since you're writing a custom server, just negotiate some protocol between you and your client to enable the client to "override" the default inactivity timeout.
As an Amazon Associate we earn from qualifying purchases.