minich@d.cs.okstate.edu (Robert Minich) (01/10/91)
[ I added c.p.appletalk and removed comp.lang.c since I feel that is appropriate ] by peter@boulder.Colorado.EDU (Peter A. Steinauer): |Ok everyone, I have a problem that I'm hoping someone can help me out with.. | I'm trying to write a simple program which will compose a packet | and send it from one socket to another on the same machine (or to | a socket on a different machine)... I'm able to open both the source | and desination [sic] sockets but when I try to compose and send the packet | DDPWrite returns a -91 in errCode which is supposed to say that the | source socket isn't open... I don't understand... Could some one | take a look at the following code and let me know what I'm missing. | I would really appreciate it... The problem is passing the correct type of parameters to Pascal functions. In this case, the socket numbers should be declared as int, according to the THINK C manual, p.120, when passed as either a parameter or, as in this case, as the destination of a pointer. So: unsigned char mySocketsource, mySocketdest; should be int mySocketsource, mySocketdest; to make errCode = DDPOpenSocket(&mySocketsource, NULL); work. Other items of interest: First, your code is not 32bit clean! You use a fake handle... > ABRecHandle myABRecHandle; > ABRecPtr myABRecPtr; > ABusRecord myABRecord; ... > myABRecPtr = &myABRecord; > myABRecHandle = & myABRecPtr; The AppleTalk code will lock down handles for ABusRecords and doing this will cause problems when your fake master pointer is not the location of the lock bit. Instead, just use... #define myABRecord (**myABHandle) ... myABHandle = NewHandle(ddpsize); HLock(myABHandle); etc. and your code will work correctly. The second point of interest is that to send things to your own node, you'll need to make sure that intra-node delivery is enabled since it's not by default. See IM V-516 about PSetSelfSend(). In researching this problem, I can't help but wonder why Apple doesn't provide DDPRead() (and LAPRead, for that matter) analogs in the preferred interface as described in IM-V. Does anyone know? It seems to me a socket listener is overkill much of the time but I assume someone somewhere had a reason to drop the calls. Other than that, the newer interface is fine and dandy. :-( Lastly, it would be nice to have the source code for the glue in the AppleTalk libraries. Symantec already provides all the source to the C libraries, so why not for Mac libraries? It's not that I want to go changing them but it's much easier to use MacsBug when I can figure out what the heck is going on during my innocent little calls. :-) -- |_ /| | Robert Minich | |\'o.O' | Oklahoma State University| "I'm not discouraging others from using |=(___)= | minich@d.cs.okstate.edu | their power of the pen, but mine will | U | - "Ackphtth" | continue to do the crossword." M. Ho