Q: What's the relationship between the classic AppleTalk PSetSelfSend call and
Open Transport AppleTalk?
A: In version 1.1, Open Transport AppleTalk shares a "self send" variable with
classic AppleTalk, i.e., if you set the variable using the classic
PSetSelfSend , the effects are seen by native clients, and vice versa.
If you're using OT native interfaces, you can change the variable using an
ioctl call, as shown in the snippet below.
enum {
kATalkFullSelfSend = MIOC_CMD(MIOC_ATALK, 47)
};
static OSStatus OTSetSelfSend(EndpointRef ep, Boolean enable_self_send)
{
OSStatus result;
result = OTIoctl(ep, kATalkFullSelfSend, (void *) enable_self_send);
if (result > noErr) {
result = noErr;
}
return result;
}
|
Note that, like the PSetSelfSend call, the ioctl returns the previous value of
the self send variable as either 0 (it was previously disabled) or 1 (it was
previously enabled). As in classic AppleTalk, it's rarely appropriate to
restore the value of self send when you're done, so the code above maps both
results to noErr .
The self send value is a Boolean , not a counter. For example, if the following
sequence happens:
- self send starts out
false
- client A sets self send to
true , is returned false as the previous value
- client B sets self send to
true , is returned true as the previous value
- client A quits, "restoring" self send to
false
then client B is left with self send set to false .
For this reason, the standard practice is to set self send if you need it and
not attempt to restore it. Because many clients follow this convention, it's
important that your program work even if self send is true.
Future versions of OT will most probably have self send always on for OT native
clients and loop-back packets will be filtered out only for classic clients if
PSetSelfSend wasn't called.
|