how to determine users' connection status

Discussion in 'C Programming' started by ligerdave, May 11, 2007.

  1. ligerdave

    ligerdave Guest

    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
     
    ligerdave, May 11, 2007
    #1
    1. Advertising

  2. In article <>,
    ligerdave <> wrote:
    >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

    --
    Dave Vandervies
    Unfortunately requiring an operating system to function properly is
    beyond the authority of the C language standard.
    --Jack Klein in comp.lang.c
     
    Dave Vandervies, May 11, 2007
    #2
    1. Advertising

  3. ligerdave

    Guest

    On May 11, 2:07 pm, ligerdave <> wrote:
    > 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
     
    , May 11, 2007
    #3
  4. ligerdave

    Guest

    In comp.os.linux.development.system ligerdave <> wrote:

    | 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.

    --
    |---------------------------------------/----------------------------------|
    | Phil Howard KA9WGN (ka9wgn.ham.org) / Do not send to the address below |
    | first name lower case at ipal.net / |
    |------------------------------------/-------------------------------------|
     
    , May 12, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?ZGF2aWQ=?=

    determine CheckBox's checkedChange status dynamically?

    =?Utf-8?B?ZGF2aWQ=?=, May 3, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    2,359
    =?Utf-8?B?ZGF2aWQ=?=
    May 4, 2005
  2. Peña, Botp
    Replies:
    1
    Views:
    265
    Robert Klemme
    Jan 24, 2004
  3. Daniel Orner

    Determine online status?

    Daniel Orner, Oct 29, 2003, in forum: Javascript
    Replies:
    2
    Views:
    99
    Daniel Orner
    Oct 30, 2003
  4. Sisyphus

    Determine connection status on Linux

    Sisyphus, Sep 24, 2003, in forum: Perl Misc
    Replies:
    4
    Views:
    97
    Sisyphus
    Sep 29, 2003
  5. Sisyphus
    Replies:
    4
    Views:
    153
    Sisyphus
    Mar 17, 2006
Loading...

Share This Page