473,473 Members | 1,988 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

how to determine users' connection status

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

May 11 '07 #1
3 1488
In article <11**********************@w5g2000hsg.googlegroups. com>,
ligerdave <da********@gmail.comwrote:
>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 dj******@csclub.uwaterloo.ca
Unfortunately requiring an operating system to function properly is
beyond the authority of the C language standard.
--Jack Klein in comp.lang.c
May 11 '07 #2
On May 11, 2:07 pm, ligerdave <david.c...@gmail.comwrote:
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 '07 #3
In comp.os.linux.development.system ligerdave <da********@gmail.comwrote:

| 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 / sp**********************@ipal.net |
|------------------------------------/-------------------------------------|
May 12 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John | last post by:
Hi there, I have been having a nightmare with one of ASP .Net 2.0 app which works fine in our development environment. WHen I move to the production server the database is getting wacked. I am...
3
by: dave | last post by:
How do I programatically determine the enabled or disabled status of AD accounts? I have queried the userAccountControl key, but all I get back is an int, and it seems to be the same for enabled...
2
by: Chris Carter | last post by:
We have a site, for reference I'll call this MainSite, that has certain pages actually hosted on another site, I'll call this ChildSite. In MainSite when you click on a certain link, it loads a...
7
by: MLH | last post by:
I have been using variations of the following to determine whether a functional connection to internet exists. I'm thinking of replacing it with a simple PING, but I've never seen any code for...
40
by: Jeff | last post by:
I have a system on a network and want to determine if anyone is currently connected to the back-end files. An interesting twist is that I have noticed that some users can be connected (have the...
7
by: semedao | last post by:
Hi all, I view many posts about this issue , the connected property does not tell us the current status of the socket. based on couple of suggestions of msdn , and some article here , I try to...
1
by: Rymfax | last post by:
I've created a Download Manager application and I'm having a problem with some clients where for whatever reason, the remote connection is forceably closed (whether on the client side or server...
0
by: Robert Avery | last post by:
In VBA/VB6, I had a class (incomplete sample below) that watched and displayed for the user all connection events, so that I could easily see what SQL was taking a long time, and when it freezes, I...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.