Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!wuarchive!udel!haven!decuac!e2big.mko.dec.com!shlump.nac.dec.com!bolt.enet.dec.com!minow From: minow@bolt.enet.dec.com (Martin Minow) Newsgroups: comp.sys.mac.programmer Subject: PPC Toolbox problem (can't make async calls) Message-ID: <19139@shlump.nac.dec.com> Date: 18 Jan 91 17:44:54 GMT Sender: newsdaemon@shlump.nac.dec.com Organization: Digital Equipment Corporation Lines: 100 When I try to use the PPC Toolbox, my application hangs in PPCInformAsync() (Using the System 7 Beta release and the Think C libraries on the Beta CD). Is this a problem with the PPC Toolbox, the Think interface glue, or my programming? Here's a sample program to illustrate the problem: All help appreciated. Martin Minow minow@bolt.enet.dec.com ------ #include OSErr status; PPCOpenPBRec pbOpenRec; PPCInformPBRec pbInform; PPCClosePBRec pbClose; PPCPortRec portRec; LocationNameRec locationNameRec; Str255 userName; short portRefNum; Boolean nbpRegistered; #define pstrcpy(dst, src) BlockMove(src, dst, src[0] + 1) int main(int argc, char *argv[]); void OpenPort(void); void TryInform(void); void ClosePort(void); void check(void); int main( int argc, char *argv[] ) { status = PPCInit(); check(); OpenPort(); TryInform(); ClosePort(); DebugStr("\pFinished"); } void OpenPort() { pbOpenRec.serviceType = ppcServiceRealTime; pbOpenRec.resFlag = 0; pbOpenRec.networkVisible = TRUE; portRec.nameScript = GetEnvirons(smSysScript); pstrcpy(portRec.name, "\pMyPortName"); portRec.portKindSelector = ppcByString; pstrcpy(portRec.u.portTypeStr, "\pMyPortType"); pbOpenRec.portName = &portRec; status = PPCOpenSync(&pbOpenRec); check(); portRefNum = pbOpenRec.portRefNum; nbpRegistered = pbOpenRec.nbpRegistered; } void TryInform() { pbInform.portRefNum = portRefNum; pbInform.autoAccept = TRUE; pbInform.portName = &portRec; pbInform.locationName = &locationNameRec; pbInform.userName = userName; DebugStr("\pThe following never returns!"); status = PPCInformAsync(&pbInform); /* <- Hangs here! */ check(); } void ClosePort() { if (portRefNum != 0) { pbClose.portRefNum = portRefNum; portRefNum = 0; /* Prevent recursion */ status = PPCCloseSync(&pbClose); check(); } } void check() { Str255 errorMsg; if (status != noErr) { NumToString(status, errorMsg); DebugStr(errorMsg); ClosePort(); ExitToShell(); } }