aspose file tools*
The moose likes Sockets and Internet Protocols and the fly likes GUI chat program 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 "GUI chat program" Watch "GUI chat program" New topic
Author

GUI chat program

sam wayne
Greenhorn

Joined: Jul 09, 2013
Posts: 3
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
Bartender

Joined: Oct 14, 2005
Posts: 18993
    
    8

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

Joined: Jul 09, 2013
Posts: 3
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
Bartender

Joined: Oct 14, 2005
Posts: 18993
    
    8

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
Marshal

Joined: Mar 22, 2005
Posts: 42951
    
  72
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

Joined: Jul 09, 2013
Posts: 3
Got it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GUI chat program