DDPRead
DDPRead Receive a datagram from another socket
#include <AppleTalk.h> AppleTalk Manager
OSErr DDPRead( abRecord, retChecksumErrs, async);
ATDDPRecHandle abRecord; handle to an ATDDPRec
Boolean retChecksumErrs; 0=FALSE; 1=TRUE
Boolean aync; 0=await completion; 1=immediate return
returns Error Code; 0=no error
DDPRead is part of the AppleTalk alternate interface. There is no equivalent
preferred call. Instead, if you want to read DDP datagrams using the
preferred interface, you must write your own socket listener and add it to the
socket table using POpenSkt. DDP will send every incoming datagram for
that socket to your socket listener. This is the recommended way to read DDP
datagrams.
DDPRead receives a datagram from another socket
abRecord is the handle of an ATDDPRec structure. The relevant fields are as
follows:
Out-InName Type Size Offset Description
¨ abOpcode ABCallType 1 0 Always tDDPRead
¨ abResult short 2 2 Result code
Æ abUserReference long 4 4 For your use
¨ ddpType short 2 8 DDP protocol type
Æ ddpSocket short 2 10 Listening socket number
¨ ddpAddress AddrBlock 4 12 Source socket address
Æ ddpReqCount short 2 16 Length of datagram data
¨ ddpActCount short 2 18 Number of frame data bytes received
Æ ddpDataPtr Ptr 4 20 Pointer to buffer
¨ ddpNodeID short 2 24 Original destination node
retChecksumErrs is a Boolean value. If TRUE, DDPRead will deliver all packets,
whether or not the checksum is valid; it will also notify the caller
when there's a checksum error.
async is a Boolean value. Use FALSE for normal ( synchronous) operation
or TRUE to enqueue the request and resume control immediately. See
Async I/O.
Returns: an operating system Error Code. It will be one of:
noErr (0) No error
ddpSktErr (-91) Socket error
ddpLenErr (-92) Datagram length too big
buf2SmallErr (-3101) Datagram too large for buffer
cksumErr (-3103) Checksum error
readQErr (-3105) Invalid socket or socket not found in table

Notes: DDPRead receives a datagram from another socket. The size and location
of the buffer that will receive the data are specified by ddpReqCount and
ddpDataPtr . If the buffer is not large enough to hold all of the incoming
frame data, the extra bytes will be discarded and buf2SmallErr will be
returned. The number of bytes actually received is returned in
ddpActCount. DDPSocket specifies the socket to receive the datagram (the
"listening" socket). The node to which the packet was sent is returned in
ddpNodeID; if the packet was broadcast ddpNodeID will contain 255. The
address of the socket that sent the packet is returned in ddpAddress. If
retCksumErrs is FALSE, DDPRead will discard any packets received with
an invalid checksum and inform the caller of the error. If retCksumErrs is
TRUE, DDPRead will deliver all packets, whether or not the checksum is
valid; it will also notify the caller when there's a checksum error.
The sender of the datagram must be in a different node from the receiver.
You should issue DDPRead calls only for receiving datagrams for sockets
opened with the default socket listener, see DDPOpenSocket.
If the buffer provided is not large enough to hold all of the incoming frame
data (buf2SmallErr), the checksum cannot be calculated; in this case
DDPRead will deliver packets even if retCksumErrs is FALSE.
Upon opening, the ability to send a packet to one's own node (intranode
delivery) is disabled. This feature of the AppleTalk Manager can be
manipulated through the SetSelfSend function. Once enabled it is possible,
at all levels, to send packets to entities within one's own node. An example
of where this might be desirable is in an application sending data to a print
spooler that is actually running in the background on the same node.
Enabling or disabling this feature affects the entire node and should be
performed with care. For instance, a desk accessory may not expect to
receive names from within its own node as a response to an NBP look-up;
enabling this feature from an application could break the desk accessory.