how to determine users' connection status

L

ligerdave

hi all,

i wonder if anyone can help me with this. im writing a program in C
under linux environment which can be connected to through telnet. in
this program, i have to manage the user information peacefully under
any circumstances. so far, if user enters quit or exit command, the
function will clear up everything nicely. however, i ran into this
crux that what if user terminate the telnet client or let's say in
case the user's computer's power went off.
so my question is very straight forward, how can i deal with cases
like this? please help. thank you all
 
D

Dave Vandervies

hi all,

i wonder if anyone can help me with this. im writing a program in C
under linux environment which can be connected to through telnet.

I'm reading this in comp.lang.c, where the correct answer to your question
is "You'll have to use something system-specific".

I think the unix answer to your question is "handle SIGHUP". The people in
the comp.os.linux.* newsgroups you crossposted to might have better ideas.

Followups set. comp.os.linux.* readers: Please remove comp.lang.c from
the crosspost list in your replies to the OP.


dave
 
S

steve_schefter

however, i ran into this
crux that what if user terminate the telnet client or let's say in
case the user's computer's power went off.
so my question is very straight forward, how can i deal with cases
like this?

This is turned on by default, but it takes about two hours for the
server to notice that the client has gone away. You can shorten
this with:
on = 1;
setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, (char *)&on, sizeof(on));
value = 2 * 60; /* every 2 minutes */
setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, (char *)&value,
sizeof(value));

Regards,
Steve
 
G

Guest

| i wonder if anyone can help me with this. im writing a program in C
| under linux environment which can be connected to through telnet. in
| this program, i have to manage the user information peacefully under
| any circumstances. so far, if user enters quit or exit command, the
| function will clear up everything nicely. however, i ran into this
| crux that what if user terminate the telnet client or let's say in
| case the user's computer's power went off.
| so my question is very straight forward, how can i deal with cases
| like this? please help. thank you all

You will either know about it quickly or delayed. You could choose to
expedite the delayed cases by instituting your own timeout rules. But
in any case, you have to decide what to do in the case of disconnection.
You could choose to force the equivalent of logging out by causing the
same logout code to be run (and be sure it is coded to be able to deal
with the fact that the connection is no longer active). Or you could
choose to leave the user status intact, ready to be re-associationed with
a connection once the user returns. You may also choose to place a time
limit on the un-associated user state and automatically log it out if the
user does not return in sufficient time.

What is to be done needs to be decided by you when you implement this.
Or you can choose to implement a variety of choices for the administrator
to choose from. But you cannot expect us to choose for you, because if
we do, you will end up with a wide variety of different opinions and have
probably even more choices to make.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top