PDA

View Full Version : Network Servers - whose connected to me?


Zenith
2003.10.01, 09:31 PM
I'm using Cocoa and BSD APIs. OK, this is the last networking question I have I swear, but I really appreciate the help.

So a few clients are connected to a server -- it's all great but, now if the server wants to send some data to ALL or SOME of the clients connected how do you do that?

Something tells me just pain write() isn't going to cut it.

Explaining this by an algorithm is fine.

Steven
2003.10.01, 11:45 PM
Your best choice (I think) would be to keep an array of all open sockets by file descriptor. Loop over them, and write() to all of them. Either that or broadcast messages over TCP or UDP, although that may be more pain than it's worth.

Zenith
2003.10.02, 11:00 AM
I see, and you get that discriptor when they connect to you right?

Steven
2003.10.02, 07:29 PM
The descriptor is what's returned by socket() and accept().