Hello... I've been working on a simple server using the sockets module and threads (just for fun btw ;p). I want to be able to connect to it by specifying a "channel" and then anything the client sends is recieved by all clients connected to the same "channel". Now I'm thinking I could make this happen by using a globally accessable list of sockets that are associated with each channel, so each client thread on the server can iterate through the list and send the same message to each client socket, but that sounds like a whole lot of iteration/workload for the server? I figured there must be a better solution to this, where perhaps each client thread monitors a shared interface of some kind? I wondered about using something like a UDP broadcast or some other kind of send-once type of method... any ideas how I could set this up? Any ideas would be greatly appreciated!!

Thanks, John

How about all the clients read from the 'channel' they are associated, and post to the 'channel' socket.

The server has only receive message, and associate to the proper channel.

Cheers and Happy coding.

Yeah, that's what I was hoping I could do but I didn't think I could connect multiple connections to one socket ? I tried something like that at first but I got a "connection already in use" type message when I tried to connect the second client. Perhaps I am mis-understanding how to implement this with sockets.... I'll try and search around some more to see if I am missing something here!
-Thanks for the idea btw!

This article has been dead for over six months. Start a new discussion instead.