Xref: utzoo comp.unix.questions:29547 comp.unix.internals:2364 Path: utzoo!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!elroy.jpl.nasa.gov!decwrl!uunet!medar!jseymour From: jseymour@medar.com (James Seymour) Newsgroups: comp.unix.questions,comp.unix.internals Subject: Re: Multiprocessing via sockets Message-ID: <84@hdwr1.medar.com> Date: 18 Mar 91 18:04:59 GMT References: <4306@skye.ed.ac.uk> <1991Mar13.053500.17782@neon.Stanford.EDU> <1991Mar15.101603.13968@thunder.mcrcim.mcgill.edu> Followup-To: comp.unix.questions Organization: Medar, Inc. Farmington Hills, MI Lines: 40 In article <1991Mar15.101603.13968@thunder.mcrcim.mcgill.edu> mouse@thunder.mcrcim.mcgill.edu (der Mouse) writes: >In article <1991Mar13.053500.17782@neon.Stanford.EDU>, sidana@neon.Stanford.EDU (Ashmeet S Sidana) writes: >> In article <4306@skye.ed.ac.uk> rbs@bute.ed.aiai (Robert Scott) writes: >>> I want to generalise the system. I want an unlimited number of >>> machine to be able to communicate. I can see that on each machine I >>> need to create an array of sockets of length N (the number of >>> machines) so that each machine can talk directly to any other. >> >> If your communication requirements are not too high then you could >> just communicate through one socket (with everybody listening), >> whereby the first byte would indicate which machine the message was >> for (assuming < 255 machines) > >Um, just how does one do this? A socket can be connected to at most >one peer. > If I understand the original question correctly, here's how ya do it (it's the way the so-called "super-daemon" works): In brief: 1) Create a daemon that listens on a "well-known" port. 2) When a connection is made, spawn a child (passing it the new socket fd) and let the child do the dirty work. 3) After spawning the child, go back and accept any more connections (if any). You can do the standard verification stuff in the child if you want (you know, the "peer" stuff). For details on this and other interesting IPC related subjects, get the book "UNIX Network Programming", written by Stevens and published by Prentice Hall. As an adjunct to this book, I also recommend "Advanced UNIX Programming", written by Rochkind and also published by P.H. [No, I don't work for the publisher :-).] Both books are clearly written and chock full of great example code. The code in the examples in the Stevens book is also available somewhere on the net (someone else here picked it up within the last couple of weeks). If I didn't understand the question correctly, I apologize in advance for the (useless?) reply. -- Jim Seymour | Medar, Inc. ...!uunet!medar!jseymour | 38700 Grand River Ave. jseymour@medar.com | Farmington Hills, MI. 48331 CIS: 72730,1166 GEnie: jseymour | FAX: (313)477-8897