Forums Register Login

request input on client/server design

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
 

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
Joel Salatin has signs on his property that say "Trespassers will be Impressed!" Impressive tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1337 times.
Similar Threads
need to create whiteboard application
Taming the network problem
Reg. Applet Chat
General question about java and servers
examples on social networking algorithms
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:59:39.