Click here to Skip to main content
15,922,145 members
Home / Discussions / C#
   

C#

 
AnswerRe: Network programming Pin
Laddie21-May-08 0:57
Laddie21-May-08 0:57 
GeneralRe: Network programming Pin
AlexPizzano21-May-08 1:49
AlexPizzano21-May-08 1:49 
GeneralRe: Network programming Pin
Laddie21-May-08 2:29
Laddie21-May-08 2:29 
AnswerRe: Network programming Pin
Le centriste21-May-08 1:52
Le centriste21-May-08 1:52 
GeneralRe: Network programming Pin
Laddie21-May-08 2:31
Laddie21-May-08 2:31 
GeneralRe: Network programming Pin
Le centriste21-May-08 2:44
Le centriste21-May-08 2:44 
AnswerRe: Network programming Pin
jithen_dt21-May-08 1:57
jithen_dt21-May-08 1:57 
AnswerRe: Network programming Pin
The Nightcoder21-May-08 4:56
The Nightcoder21-May-08 4:56 
Hi,

In order to catch all cases, I would suggest a heartbeat function (as was already suggested). Some details (drawn from specs I've encountered interfacing with various industrial PLC systems):

- If your client sessions don't use persistent TCP connections (if you are using an HTTP request for each transaction, for example), you're correct in noting that you can't contact the client from the server gratuitously. In that case, have the client contact the server with a dummy message with a specific interval (unless it has already talked to the server during the interval) and let the server invalidate sessions that haven't been heard from in, say, twice that interval.

- If you do use persistent TCP connections (that stay open for the duration of the client session) you can contact the clients from the server (you can write to the socket from either direction as long as it's open). You could then send an "are you alive?"-message to clients you hadn't heard from in a while - you will get an exception if the TCP/IP stack has given up on the connection, a response if not and the client is alive, no response if the client is dead but the TCP/IP stack hasn't realized it yet. The benefit of this is that you can tune the timer intervals on the server without having to change or inform the clients.

Reasonable interval would be application specific, but beware of swamping the server with keep-alives if you could have a lot of clients.

One crane controller protocol I use requires keepalives be sent each minute (by both ends) and any party that hasn't heard anything for two minutes closes and gives up on the connection (if it's the client that gives up, it starts attempting to reconnect to the server - this also has a timeout and will be repeated indefinitely, as the protocol is built for stuff that should be connected at all times). Persistent TCP connections are used here.

Useful?

--
Peter

GeneralRe: Network programming Pin
Laddie21-May-08 5:07
Laddie21-May-08 5:07 
Question[Message Deleted] Pin
csetopper_bhanu21-May-08 0:23
csetopper_bhanu21-May-08 0:23 
AnswerRe: database connectivity Pin
Christian Graus21-May-08 0:31
protectorChristian Graus21-May-08 0:31 
GeneralRe: database connectivity Pin
Le centriste21-May-08 1:54
Le centriste21-May-08 1:54 
AnswerRe: database connectivity Pin
originSH21-May-08 0:32
originSH21-May-08 0:32 
GeneralRe: database connectivity Pin
csetopper_bhanu21-May-08 0:38
csetopper_bhanu21-May-08 0:38 
GeneralRe: database connectivity Pin
csetopper_bhanu21-May-08 1:28
csetopper_bhanu21-May-08 1:28 
Question[Message Deleted] Pin
venkat86_ece20-May-08 23:48
venkat86_ece20-May-08 23:48 
AnswerRe: Generate time table Pin
Gareth H20-May-08 23:59
Gareth H20-May-08 23:59 
AnswerRe: Generate time table Pin
originSH21-May-08 0:00
originSH21-May-08 0:00 
AnswerRe: Generate time table Pin
Christian Graus21-May-08 0:00
protectorChristian Graus21-May-08 0:00 
GeneralRe: Generate time table Pin
Spunky Coder21-May-08 0:11
Spunky Coder21-May-08 0:11 
GeneralRe: Generate time table Pin
J4amieC21-May-08 1:10
J4amieC21-May-08 1:10 
GeneralRe: Generate time table Pin
MumbleB21-May-08 2:21
MumbleB21-May-08 2:21 
QuestionExport to Excel File Size Issue Pin
rrprabu20-May-08 23:30
rrprabu20-May-08 23:30 
QuestionStringBuilder ' escape sequence Pin
StyleGuide20-May-08 22:44
StyleGuide20-May-08 22:44 
AnswerRe: StringBuilder ' escape sequence Pin
Bekjong20-May-08 23:05
Bekjong20-May-08 23:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.