xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

INetDGramRecv()

Reads data from a datagram socket.

Syntax

INetDGramRecv( <pSocket>, ;
              @<cBuffer>, ;
              [<nBytes>]  ) --> nReceivedBytes

Arguments

<pSocket>
This is a pointer to a socket as returned by INetDGram() or INetDGramBind()
<cBuffer>
A memory variable holding a character string must be passed by reference to INetDGramRecv(). It must have at least <nBytes> characters.
<nBytes>
This is a numeric value specifying the number of bytes to transfer from the socket into the memory variable <cBuffer>. It defaults to Len(<cBuffer>).

Return

The function returns a numeric value indicating the number of bytes read from the socket. If the return value is smaller than Len(<cBuffer>), either no more bytes are available, or a network error ocurred. This can be identified using function INetErrorCode().

Description

INetDGramRecv() blocks the current thread until <nBytes> bytes are read from a datagram socket <pSocket>. The received bytes are copied into the memory variable <cBuffer>, which must be passed by reference.

To avoid blocking, function INetDataReady() can be used to detect if incoming data is available, or a timeout value can be set with INetSetTimeout().

Note:  it is not guaranteed that all the data required to be read is sent from the kernel to the application. The kernel just returns the last complete datagram that has been received, up to <nBytes> bytes.

Refer to function INetDGramSend() for an example of datagram exchange between two processes.

Info

See also:INetDGram(), INetDGramBind(), INetDGramSend(), INetSetTimeout()
Category: Datagram functions , Sockets functions , xHarbour extensions
Source:vm\INet.c
LIB:xhb.lib
DLL:xhbdll.dll


Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe