This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
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).
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.
Joined: Jul 09, 2013
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. .
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?