Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Networking /
Chapter 7 - Datagram Delivery Protocol (DDP) / DDP Reference
Routines / Sending DDP Datagrams


PWriteDDP

The PWriteDDP function sends a DDP datagram to another socket.

FUNCTION PWriteDDP (thePBptr: MPPPBPtr; async: Boolean): OSErr;
thePBptr
A pointer to an MPP parameter block.
async
A Boolean that specifies whether the function should be executed asynchronously. Specify TRUE for asynchronous execution.
-->ioCompletionProcPtrA completion routine.
<--ioResultOSErrThe result code.
-->csCodeIntegerAlways writeDDP for this function.
-->socketByteThe number of socket to send data from.
-->checksumFlagByteThe checksum flag; nonzero to
compute checksum.
-->wdsPointerPtrA pointer to write-data structure.

Field Description
socket
The number of the socket from which you want to send data. See the description of the POpenSkt function for information on the assignment of socket numbers.
checksumFlag
The checksum flag. If you set this field to a nonzero value and if DDP uses a long header for the datagram (that is, if the destination socket has a network number different from that of the source socket), then the PWriteDDP function calculates a checksum for the datagram and includes it in the datagram header. Set this field to 0 if you do not want the PWriteDDP function to calculate a checksum.
wdsPointer
A pointer to a write-data structure. The write-data structure provides the destination address and the data for the datagram.
The DDP write-data structure is described in "Creating a DDP Write-Data Structure" on page 7-12.
DESCRIPTION
Before you call the PWriteDDP function, you must prepare a write-data structure.
The write-data structure, shown in Figure 7-4 on page 7-13, includes a pointer to the destination address and pointers to buffers containing the data you wish to send.
You can use the BuildDDPwds procedure to build a write-data structure.

Set the checksum flag field when you call the PWriteDDP function to have the function calculate the checksum and include it in the packet header. Note, however, that only
long packet headers include a checksum field, and that whether the checksum is used
for error checking depends on how the socket listener code at the destination socket is implemented.

The PWriteDDP function is equivalent to calling the PBControl function with a value of writeDDP in the csCode field of the parameter block.

SPECIAL CONSIDERATIONS
Memory used for the write-data structure belongs to DDP and must be nonrelocatable until the PWriteDDP function completes execution, after which you can either reuse the memory or release it.

ASSEMBLY-LANGUAGE INFORMATION
To execute the PWriteDDP function from assembly language, call the _Control trap macro with a value of writeDDP in the csCode field of the parameter block. You must also specify the .MPP driver reference number. To execute the _Control trap asynchro-
nously, include the value ,ASYNC in the operand field.

RESULT CODES
noErr0No error
ddpSktErr-91Bad socket number
ddpLenErr-92Datagram data exceeds 586 bytes
noBridgeErr-93Could not find router to forward packet
SEE ALSO
For a description of the DDP write-data structure, see "Creating a DDP Write-Data Structure" on page 7-12.

If you are programming in Pascal or C, see the description of the BuildDDPwds procedure that follows for help in creating a write-data structure.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996