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 two server and many client.... 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 "two server and many client...." Watch "two server and many client...." New topic

two server and many client....

mark smith
Ranch Hand

Joined: Apr 05, 2005
Posts: 251

what i want to do is to create to start 2 tread of server in my class main server....
and each class server start a thread for each connection...

example server1 start with port 4444 and server2 with port 4445

all client connect to server1 except if the server is down...

my code

ServerMain class

Server class

client class
i need to add function to be able to try during 10 second to connect to server 1(4444).... i the server don't respond... i try to connect to server2 (port 4445)

i start ServerMain

and after i start i client

the server write a lot of:
connexion successfull...

any idea?

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Your server is starting a lot of ServerThreads without actually getting any connection requests from clients. This kind of thing is common:

Once you have a ServerSocket open you need to wait for inbound connection requests. I start a new MessageHandler for each new connection using threads in a pool. Does that make sense?

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: two server and many client....
It's not a secret anymore!