soe@ames.arc.nasa.gov (Brad Soe) (12/20/88)
I want to implement a driver or INIT that will alert a user when he has received new mail. When a user recieves mail, a packet is sent out to the macintosh, and if it is on, a message is displayed on the screen. I want to implement something like Tops, where a connction is made when the system starts up, and then it runs while the mac is doing other things. I am not 100% sure how to implement it, nor what is the best way to do it. I want to write a piece of code, that will open a socket to the Appletalk when the system starts up, then poll and wait for packets while the Mac is running and doing other things. I want it to be a DA, so that when the Mac gets a packet for it will use the Notification Manager to tell the user that there is something there for it. This is what I think I need. I need an INIT that will make a call to a drivers open command, to start the connection, and register the connection to be closed when the system shutsdown. Is there a way to create a driver to be started (opened) when the system starts up, or do I need an INIT that will start it for me. Also, I am not that handy with assembly language, so I would like to write as much C code as possible. I am just looking for the best possible solution to the problem. Thanks Brad Soe soe@ames.arc.nasa.gov
jln@accuvax.nwu.edu (John Norstad) (12/20/88)
Brad Soe asked about writing an INIT to notify users of new mail. It wasn't clear whether the mail machine is sending you unsolicited packets notifying you of new mail, or whether you want to periodically poll the mail machine and ask if it has new mail. If you want to poll, you should write an INIT that opens a socket for the polling and installs a VBL task. The VBL task wakes up periodically, sends a message to the mail machine out the socket, and waits for a reply. If and when a reply arrives saying that there is in fact new mail, the VBL task calls the notification manager to alert the user. If you don't want to poll, just wait for notification packets, then you should write an INIT that opens a socket and installs a pair of completion routines in the system heap. You need an ATPGetRequest completion routine and an ATPSendResponse completion routine. The ATPGetRequest completion routine waits for notification packets to arrive. When one arrives, it calls the notification manager to alert the user and sends a response. The ATPSendResponse completion routine waits for the response to be acknowledged (I'm assuming you're using exactly once service), and issues the next GetRequest. The INIT issues the first GetRequest. In both of these scenarios you must use asynchronous AppleTalk calls, which requires at least some assembly language glue. There's no need for a DA in either of these cases. You can call the notification manager from a VBL task or completion routine without having to specify an application or DA. It's all fairly complicated, but doable. I have a half-finished AppleTalk program which uses the second scheme above. The INIT is in MPW C, while the completion routines are in MPW Assembler. You're welcome to a copy of my code. The INIT and completion routines are finished, debugged, and pretty well documented. Write to me if you'd like a copy. John Norstad Academic Computing and Network Services Northwestern University Bitnet: jln@nuacc Internet: jln@acns.nwu.edu