Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

GUI chat program

 
sam wayne
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have made command line multi client chat program but am having trouble in making GUI based,,, I am very confused about my approach(howmany classes should i make, how shoud i arrange them, which part shoud be GUI and where ....etc.)

One of main problems is that the server starts with the 1st instance of chat program and rest all instances (of chat program) just instantiate client...if 1st instance of chat program is closed,,,server is closed for all...
How to instantiate server with one chat instance but make it stoppable by all other instances(of chat program)...?

Can someone suggest me something(approach for starting and soln for given problm).
 
Paul Clapham
Sheriff
Pie
Posts: 20771
30
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sam wayne wrote:One of main problems is that the server starts with the 1st instance of chat program and rest all instances (of chat program) just instantiate client...


Welcome to the Ranch, Sam!

But that's rather a strange design. In a real client-server application the server would run all the time, waiting for connections from clients. The idea that a client would start the server if it can't find a server is not very practical -- what happens if two clients start up at the same time and both start "the" server? And how is the second client supposed to look for the server when any other client on any other computer might already have started it?

So I'd suggest you go with the ordinary design where the server runs as a standalone application on a predefined machine at a predefined port, and the clients connect to that server.
 
sam wayne
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.. you are right..I was little confused...
I have made a servergui.java and clientgui.java , they work perfectly when I start server and then desired no of clients...can you tell me how to combine them in one Application so that 1st time it is launched a server is created alongwith a client and for rest only clients are created. .
 
Paul Clapham
Sheriff
Pie
Posts: 20771
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sam wayne wrote:can you tell me how to combine them in one Application so that 1st time it is launched a server is created alongwith a client and for rest only clients are created. .


No. Not "can't" but "won't", because I already tried to explain why that wasn't a practical idea. Are you particularly attached to that idea? If so, why?
 
Ulf Dittmer
Rancher
Pie
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't start the server on some random machine where the first client to be started happens to run, because then the other clients won't know which machine to connect to. As Paul said, client and server run independently of one another. What are you trying to achieve by integrating them?
 
sam wayne
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Got it.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic