Network Servers - whose connected to me?

Zenith
Unregistered
 
Post: #1
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.
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #2
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.

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Zenith
Unregistered
 
Post: #3
I see, and you get that discriptor when they connect to you right?
Quote this message in a reply
Member
Posts: 370
Joined: 2002.04
Post: #4
The descriptor is what's returned by socket() and accept().

Did you ever wonder why we had to run for shelter when the promise of a brave new world unfurled beneath the clear blue sky?
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  java network api San_Andreas 1 3,143 May 1, 2008 08:05 AM
Last Post: AndyKorth
  Getting network connection for a specified PID Florian 6 4,909 Dec 23, 2006 03:46 AM
Last Post: Florian
  Master Game Servers Services SethWillits 6 5,859 Jul 18, 2006 04:28 PM
Last Post: SethWillits
  Ways to Network. BinarySpike 28 12,386 May 10, 2005 07:44 PM
Last Post: kodex
  Network play David 15 7,417 Apr 10, 2003 05:56 AM
Last Post: rvangaal