Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!decwrl!shlump.dec.com!mountn.dec.com!minow From: minow@mountn.dec.com (Martin Minow) Newsgroups: comp.sys.mac.programmer Subject: Re: Distributed data collection Message-ID: <271@mountn.dec.com> Date: 9 Jun 89 14:00:58 GMT References: <5167@pt.cs.cmu.edu> Reply-To: minow@mountn.UUCP (Martin Minow) Organization: Digital Equipment Corporation Lines: 49 In article <5167@pt.cs.cmu.edu> mkb@rover.ri.cmu.edu (Mike Blackwell) describes a system he's building that will collect data from a number of Macs which will be saved in a central database. I did exactly that for program that was used in the pressroom of this year's Boston Marathon: two computers collected intermediate timings and transmitted the results to two other computers that managed large screen displays. I programmed this using AppleTalk: the display managers were servers to the data collection clients, and think this was a good choice. I actually wrote both the server and client modules in the same application with a startup dialog that let the user choose between "server," "client", or "both" -- the latter let me debug the entire application on a single computer without a network connection. The overall event loop had (very roughly) the following organization: for (;;) { ... normal Macintosh event processing ... for (all server packets) { if (server_request[i]->atp.ioRequest <= 0) process_incoming_server_packet(); } for (all client packets) { if (client_request[i]->atp.ioRequest <= 0) { check for errors, then free the packet; } } } The client (data entry side) sends a message by getting a free packet, loading it up, setting the atp.ioRequest to +1 (can't be a result code) and sending it by PSendRequest(&client_request[i]->atp, ASYNC). When the request completes, process_client_server_packet() checks for errors or server response status and frees the packet. The server (display side) queues up all of its free packets for asychronous reception (calling PGetRequest(..., ASYNC)). Incoming server packets are checked for errors, then handled by message-type specific handlers and eventually requeued for another request. Note that all I/O is asychronous. I/O completion is detected in the event loop polling sequence. Hope this helps. Martin Minow minow%thundr.dec@decwrl.dec.com