• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

two server and many client....

 
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi

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?

thanks
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
First, you drop a couch from the plane, THEN you surf it. Here, take this tiny ad with you:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic