File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes Multiple Connections to a Server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Multiple Connections to a Server" Watch "Multiple Connections to a Server" New topic

Multiple Connections to a Server

Submit Plastic

Joined: Aug 13, 2004
Posts: 1
I have recently expanded my JAVA'ing from doing basic applets for my sites and such, into doing a lot of web based applications. I have been trying to figure out how to get multiple people to connect to a java server at once. I tried using threads, and thought I was on the right track, but i keep hitting dead ends. Any help would be great.

Warren Dew
Ranch Hand

Joined: Mar 04, 2004
Posts: 1332
Not sure what you mean by a "Java server", but if they are web based applications, shouldn't a web server like Apache, with a Java/JSP application server like Tomcat, do the job?
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
If you're writing your own server - a fun and educational experience - you'll have a ServerSocket somewhere that does accept(). This gives you a socket that is connected to the client. If you put all processing of the socket on another thread, the main thread can be ready to accept another connection in no time at all. Here are few lines from my Wiki server ...

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: Multiple Connections to a Server
It's not a secret anymore!