Important: The information in this document is obsolete and should not be used for new development.
ERead
When you use the default protocol handler for Ethernet that Apple provides, you must use theEReadfunction to read a data packet and place it in a data buffer.
FUNCTION ERead (thePBptr: EParamBlkPtr; async: Boolean): OSErr;
thePBptr- A pointer to a parameter block of type
EParamBlock.async- A Boolean value that specifies whether the function should be
executed asynchronously or synchronously. SpecifyTRUEfor asynchronous execution.
--> ioCompletion ProcPtr A pointer to completion routine. <-- ioResult OSErr The result code. --> ioRefNum Integer The driver reference number. --> csCode Integer Always ENetReadfor this function.--> eProtType Integer The Ethernet protocol type. --> ePointer Ptr A pointer to a data buffer. --> eBuffSize Integer The size of the data buffer. <-- eDataSize Integer The number of bytes read.
Field Description
eProtType- The protocol type of the packet you want to read.
ePointer- A pointer to the data buffer into which you want to read data.
eBuffSize- The size of the data buffer. If you are expecting Ethernet data packets, the buffer should be at least 621 bytes in size; if you are expecting general Ethernet data packets, the buffer should be at least 1514 bytes in size.
eDataSize- The number of bytes of data actually read.
DESCRIPTION
You can use theEReadfunction to read packets of a particular protocol type only after you have used theEAttachPHfunction to specify aNILpointer to the protocol handler to indicate that you want to use the default protocol handler. In practice, you should call theEAttachPHfunction very early, during your program initialization sequence, if possible. As soon as the connection is established and you are expecting data, you should call theEReadfunction asynchronously.The
EReadfunction places the entire packet, including the packet header, into your buffer. The function returns in theeDataSizeparameter the number of bytes actually read. If the packet is larger than the data buffer, theEReadfunction places as much of the packet as will fit into the buffer and returns thebuf2SmallErrresult code.Call the
EReadfunction asynchronously to await the next data packet. When the .ENET driver receives the data packet, it completes execution of theEReadfunction and calls your completion routine. If the .ENET driver receives a data packet with a protocol type for which you specified the default protocol handler while noEReadcommand is pending, the driver discards the data packet.You can have several asynchronous calls to the
EReadfunction pending execution simultaneously as long as you use a different parameter block for each call.SPECIAL CONSIDERATIONS
You must not use theEReadfunction to read packets if you supply and attach your own protocol handler. In this case, you use the driver'sReadPacketandReadRestroutines from within your protocol handler.TOKEN RING AND FDDI CONSIDERATIONS
This function does not apply to token ring and FDDI.ASSEMBLY-LANGUAGE INFORMATION
To execute theEReadfunction from assembly language, call the_Controltrap macro with a value ofENetReadin thecsCodefield of the parameter block. To execute the_Controltrap asynchronously, include the value,ASYNCin the operand field.RESULT CODES
noErr 0 No error LAPProtErr -94 No protocol is attached or protocol handler pointer
was not 0reqAborted -1105 ERdCancelorEDetachPHfunction calledbuf2SmallErr -3101 Packet too large for buffer; partial data returned SEE ALSO
See "Using the Default Ethernet Protocol Handler to Read Data" beginning on page 11-13 for more information on using theEReadfunction.