Hey guys, I have two questions. I have a multithreaded server that is able to process requests from more than one client at a time. However, my server has a habit of shutting down after a while, despite that I have an infinite while loop to keep it accepting connections.

Also, how do I get my to run my client on a different machine and connect to my own machine? I tried connecting my client to my public ip (cos my server's in my machine), but it wouldn't connect.

Also, how do I get my to run my client on a different machine and connect to my own machine? I tried connecting my client to my public ip (cos my server's in my machine), but it wouldn't connect.

"localhost" 127.0.0.1 usually works, public IP is likely to be a problem if you have a NAT router anywhere.

However, my server has a habit of shutting down after a while, despite that I have an infinite while loop to keep it accepting connections.

Are you closing the connections after you have finished with them, or are you just creating an ever-growing heap of them?

Edited 6 Years Ago by JamesCherrill: n/a

Do you get any errors when the server stops. Can you add some messages to be printed before it stops?

Nope. No errors. Server just stops.

"localhost" 127.0.0.1 usually works, public IP is likely to be a problem if you have a NAT router anywhere.

Are you closing the connections after you have finished with them, or are you just creating an ever-growing heap of them?

If I put localhost or 127.0.0.1, wouldn't the client be looking for a server on the machine it's installed in, rather than looking for a server on another machine (which is what I want?). At the moment I use localhost, cos the server and client are both on the same computer.

As for the second question, I do close the input/output connections of each thread after their done

Do all the catch blocks do prints of some kind?
Do you run the server with a console window that will be open when the server stops that could show any error messages?

Do all the catch blocks do prints of some kind?
Do you run the server with a console window that will be open when the server stops that could show any error messages?

Yeah Norm, all catch blocks print something if there's an error. I run my servers using the windows command line. Sometimes I run it on my eclipse console. Nothing different, really. After a while they both stop. It's not for a short while though. But I just thought it shouldn't have to stop until I put in a code to make it stop.

Sorry about the localhost thing - I misread your original post.
Does it stop after a consistent amount of time? Or is it possibly a consistent number of connections? Maybe a bit of logging of times & connection counts could reveal something about the problem?

What does stop mean? The program exits? or it hangs not doing anything?

Program exists. It doesn't hang. It just stops running...

Sorry about the localhost thing - I misread your original post.
Does it stop after a consistent amount of time? Or is it possibly a consistent number of connections? Maybe a bit of logging of times & connection counts could reveal something about the problem?

It's more to do with time than connections, from all the tests I carried out. I have println statements that inform me of serveral areas in the server and what the server and client are doing. I also have codes like this in the client.

Make no mistake, my server has never shuts down while in the middle of processing a client. It only goes offline when it's not processing clients, or when it hasn't processed clients for a while, which is why i asked if there's some kind of timeout involving client/server using SSL connections.

This article has been dead for over six months. Start a new discussion instead.