aspose file tools*
The moose likes Distributed Java and the fly likes request input on client/server design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Distributed Java
Bookmark "request input on client/server design" Watch "request input on client/server design" New topic
Author

request input on client/server design

Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 236
Hi there,

I'm considering doing a project that involves collaborative client/server application involving chat, whiteboard, VoiP, etc.

My question is this...would each aspect of the project (chat, whiteboard,etc) require that it run on a seperate port to the server? Is that normal from a design perspective? I'm thinking a seperate thread on the server listening on different ports: one for the chat (port 2000), one for the whiteboard(port 2001), one for VoiP(port 2002), etc.

I'm only thinking of this approach as being favourable because the types of data being moved back and forth would be different on each port. Does this make sense? Are there some other approaches to this type of project?

Alan
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
I don't think there's any problem with using several ports that way. A single port might make life a lot easier if you have to get them opened on a firewall. It also simplifies what clients have to know about the server.

You can accept all request messages on one port and dispatch them to appropriate subsystems based on content. Read up on Strategy Pattern and see if this make sense:

The header might be CHAT or WHITEBOARD. The HandlerFactory might just be a HashMap where CHAT returns a ChatRequestReader. I like factories like that because you can add new headers and handlers through configuration without touching the dispatcher code.

Does that sound useful? Are you comfortable managing multiple threads for inbound requests?


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 236
I've used multi-threading before in standalone apps but not when trying to configure a server app.

Perhaps you can direct me to a tutorial or something that explains your idea in greater detail?

Alan
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
The classic socket server does something like:

This runs each new request on a new thread. In Java5 and later with only a couple more lines you can run requests on a thread pool to reduce thread setup and teardown. Does that look like something you can use?
Alan Shiers
Ranch Hand

Joined: Sep 24, 2003
Posts: 236
Originally posted by Stan James:



I'm more interested in this snippet of code. This seems to suggest that I can somehow read each packet as it comes in and determine if is of a particular protocol. Is that possible? Certainly it would be good to read the packets as they arrive so that I can then determine to which handler to send them.

Alan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: request input on client/server design
 
Similar Threads
Reg. Applet Chat
examples on social networking algorithms
General question about java and servers
Taming the network problem
need to create whiteboard application