Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 15th, 2006, 9:41 PM   #1
krazyshane
Newbie
 
Join Date: Dec 2005
Posts: 7
Rep Power: 0 krazyshane is on a distinguished road
Java Socket Timouts in a Chat client/server

Okay, I have created a chat client/server application in Java. This was a fun project and was my first experience with multithreading and sockets.

The code works great. I have a working chat client/server that allows for multiple users, user listings, formatting type etc.

My question is about timing out. It seems that the client will stay connected indefinitely as long as there is chat going on. If however there is not, the client will be disconnected (I dont know what the timout is).

Anyways, I've thought about just having a timer thread that sends a packet just to keep the connection alive after (x minutues). Is there a simpler way to ensure that the connection wont timeout? If not, how long should i wait between keepalive packets?

Thanks,
Shane
krazyshane is offline   Reply With Quote
Old Feb 16th, 2006, 9:35 PM   #2
krazyshane
Newbie
 
Join Date: Dec 2005
Posts: 7
Rep Power: 0 krazyshane is on a distinguished road
Lol 21 views and no replies. You guys werent much help.

I just created a keepalive class on the client side that sends a 1Byte packet every minute. Works.

Shane
krazyshane is offline   Reply With Quote
Old Feb 16th, 2006, 10:49 PM   #3
jaeusm
Programmer
 
jaeusm's Avatar
 
Join Date: Feb 2006
Location: Columbus, OH
Posts: 84
Rep Power: 3 jaeusm is on a distinguished road
Quote:
Lol 21 views and no replies. You guys werent much help.
I have not had the problem you stated. If you don't specify the timeout, the socket in the server thread handling a client should block indefinitely, which is how my code works. Maybe I'm not understanding your problem.
jaeusm is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:06 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC