Catching exceptions....Client crashes....

I have written a Server and Client program for my Final Year Project, its a 2D Chat room with 4 different chat room environments.

It pretty cool and Ill be releasing it as freeware soon enough once I learn how maybe to prevent people from saying its their own, if you know what I mean.

Ok heres the problem. I was testing it yesterday and I had 8 users logged in from one machine. I tried to simulate 8 client programs crashing in one go; I did this by resetting the PC.

Now I though the server would of realised immediately. Each client that is connected to the server has one thread allocated to it, which sits and listens for incoming messages and when a message comes in it deals with it and passes it on to the other clients. Now I thought that when the client crashes there is an exception thrown where the thread is listening for user messages. And I have it that when it happens it cleans up and updates all the other connected users e.g. removes the user from the room, update the amount of users count in the room in all the other users GUIs.

Now when I did this test yesterday I took a while for the server to realise. Now dont be mistaken; there was no deadlock or anything else like that. Cause the program didnt freeze up. All the users were removed from the server within 1 minute of it happening.

I am using TCP sockets by the way.

But I am wondering why it didnt happen immediately?

Any suggestion ?

Thanks,

Tommy

[1509 byte] By [zoltan_ie] at [2007-9-27 3:01:46]
# 1
Well, what makes you think that a socket knows immediately when a partner - on the other end - crashes? What mechanism would you propose to instantly communicate this fact?
bschauwe at 2007-7-4 23:47:43 > top of Java-index,Archived Forums,Socket Programming...
# 2
I suppose I should be using some sort of polling mechanism. As in send the user a message every once in a while and expect a reply, and if there's no reply that means the client has crashed.
zoltan_ie at 2007-7-4 23:47:43 > top of Java-index,Archived Forums,Socket Programming...
# 3

May I say something? I dont think you even have a problem. Java, Sockets, and the network are doing their jobs just well. Think of this: Your working with a 56K dial-up link over the WWW from point A to point B, the distance of which is up to thousands of miles apart. Then think of this, your Network OS may also be a little slow with traffic, then higher-level inter-connected networks, the phone companies, etc are all giving overhead to the traffic flow.

Being a little slow, it just the nature of the beast! Hey wouldnt be cool if we all just got curb-to-home optical connections like OC-3? He he he.

watertownjordan at 2007-7-4 23:47:43 > top of Java-index,Archived Forums,Socket Programming...
# 4

Cheers, I though I'd end up in some sort of trouble as I though it was some kinda bad programming on my part. Went to my final year project advisor and explained it to him. He said not to worry.

well here the project anyway. My first Java Program: A 2D Chat room with 4 different chatroom enviroments

http://www.geocities.com/thomasjkeegan/vrchat/vrchat.html

zoltan_ie at 2007-7-4 23:47:43 > top of Java-index,Archived Forums,Socket Programming...
# 5
Checked out the site - vary nice for college kid!I do professional, but I would hire you!Next, try adding streaming voice/video over the applet link.
watertownjordan at 2007-7-4 23:47:43 > top of Java-index,Archived Forums,Socket Programming...