Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

two server and many client....

 
Ranch Hand
Posts: 263
  • 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?
reply
    Bookmark Topic Watch Topic
  • New Topic