asking help for a peer-to-peer socket programming question

asking help for a peer-to-peer socket programming question

Post by mgessne » Thu, 17 Jul 2003 22:28:28

I've been thinking about this for a little bit now. I think you need
to ask/answer some question about what you're trying to do, because if
you don't give careful consideration to some limitations, you're going
to hit a wall.

a) How many concurrent children do you want to support?

If the number is small (a couple hundred), I'd suggest using pipes between
each child and the parent, and each child can send messages to the parent
which the parent will broadcast out it's collection of active pipes.

You could probably also do the same thing with sockets or shared memory.

b) Are there enough resources configured in the kernel to allow for this?

If not, you're going to have to go in and tweak your kernel. If there's not
enough physical resources, you're going to need to add some :) This is only
if you're planning to have a really big number.

You might consider looking at how IRC servers are designed. They do much
the same thing as I understand you're trying to do. This is only if you
are very brave :)

Next: how are you planning on doing this without select()? You don't give
too many details, but as I see it, you're going to have at least 2 active
IPC paths for each child: one to the parent, and one to the client. You're
going to need some way to do this. Are you going to use non-blocking
sockets or something like that?

Good luck.


asking help for a peer-to-peer socket programming question

Post by g1461 » Fri, 18 Jul 2003 13:21:54


Thank you very much to help me out. Please refer to the insertion for
the answers to your questions.


Amy's answer: Only ten children I want to support ( it is a really
tiny chat server)

Amy's answer: Yes, it is a non-blocking and concurrent server. I use
fork() to have the child process to handle login client and let parent
listen to the incoming request. Since broadcast chatting messages is
required, so I have to make the old children know the newly incoming
clients' information (socket discriptor)in order to broadcast messages
to them.