permaculture playing cards
The moose likes Sockets and Internet Protocols and the fly likes Chat Server Design? 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 "Chat Server Design?" Watch "Chat Server Design?" New topic

Chat Server Design?

Brian Smithy

Joined: Feb 18, 2007
Posts: 1
Hello, I have been in the process of working on a simple (very simple) java chat server... it handles the clients with threads and I can even connect to it, send it data and have it send it back, only problem is that it is not broadcasting it to all the connected clients, only the one that sent the data.

I am fairly new to OOP programming, and I started to make my own way to handle clients, but it didnt help work.

I feel there is something I am missing, ive been struggling for days on this, ive been looking up multicasting, but I am not sure if thats what I want.

If anyone could provide me with some insight on how I should handle the clients, broadcast the packets, and anything else, I would appreciate it. I am not asking for code, just design concepts (but code would be nice, just keep it very simple, I do not want to be spoon fed )
Joe Ess

Joined: Oct 29, 2001
Posts: 9189

Welcome to the JavaRanch, Brian.
Multicasting is probably a bad match for your task as it uses UDP and you don't have guaranteed delivery with UDP.
The first thing that I think of would be to have the server store all your client connections somewere and every time it receives a client message, use that store to forward the message to each client. Does that sound do-able?

[How To Ask Questions On JavaRanch]
I agree. Here's the link:
subject: Chat Server Design?
jQuery in Action, 3rd edition