hb_inetRecvEndblock()

HB_INETRECVENDBLOCK()

Read a block from a socket

Syntax

      HB_INETRECVENDBLOCK( <socket> [, <cBlock >[, @<nBytesRead> ;
                           [, <nMaxLength> [, <nBufSize> ]]]] ) 
                           -> cResult

Arguments

<socket> a socket previously created / opened

<cBlock>

<nBytesRead>

<nMaxLength>

<nBufSize>

Returns

Block read

Description

This function operates exactly the same way as hb_InetRecvLine, but the “record termination” is customizable through the cBlock parameter. If not given, this parameter defaults to the CRLF sequence. Provided by: Marcelo Lombardo

Compliance

Harbour

hb_inetRecvAll()

HB_INETRECVALL()

Read from a socket without blocking

Syntax

      HB_INETRECVALL( <socket>, @<cResult>, [ <nAmount> ] ) -> nResult

Arguments

<socket> a socket previously created / opened

<cResult> is the target buffer and must be passed by reference

<nAmount> is the upper limit of characters to be read from the socket. If not passed this defaults to the length of cResult

Returns

The number of the characters read from the socket. Might be less than nAmount on premature socket closing or on network error.

Description

This function works exactly as hb_InetRecv except that it blocks until nAmount bytes are read, if nAmount is given, or cString is filled for its whole length.

Compliance

Harbour

hb_inetRecv()

HB_INETRECV()

Read from a socket

Syntax

      HB_INETRECV( <socket>, @<cResult>, [ <nAmount> ] ) -> nResult

Arguments

<socket> a socket previously created / opened

<cResult> is the target buffer and must be passed by reference

<nAmount> is the upper limit of characters to be read from the socket. If not passed this defaults to the length of cResult

Returns

The number of the characters read from the socket.

Description

Reads from the socket into a buffer.

The parameter cString must be preallocated so that it has enough space to receive the data. The routine will block the thread until some bytes are read from the socket, the socket is closed (either from the receiver or the sender side) or a network error occurs, whichever comes first. In the latter cases, an error is set, and only the characters received until premature end of communications are returned.

Notice that there is no guarantee that all the available bytes will be read before the function returns, in fact, hb_InetRecv returns as soon it is able to fill cString with one or more bytes. To block the current process until the whole cString is filled (or nAmount bytes are read), use the hb_InetRecvALL().

Compliance

Harbour

hb_inetPort()

HB_INETPORT()

Get the port a socket is bound to.

Syntax

      HB_INETPORT( <socket> ) -> cResult

Arguments

<socket> a socket previously created / opened

Returns

Port name the socket is bound to.

Description

Returns the port to which this socket is bound, or the remote port if this socket is connected with a remote host or client

Compliance

Harbour

hb_inetPeriodCallback()

HB_INETPERIODCALLBACK()

Get or change the periodic callback value of a socket

Syntax

      HB_INETPERIODCALLBACK( <socket> [, <xCallback> ] )
                              -> xPreviousCallback

Arguments

<socket> a socket previously created / opened

xCallback a new periodic callback

Returns

The previous periodic callback value

Description

Sets or returns the socket periodic callback value

xCallback can be one of: a codeblock, an array of (…), or a (symbol) TODO: describe these better

Compliance

Harbour

hb_inetInit()

HB_INETINIT()

Activate Harbour INET support

Syntax

      HB_INETINIT() -> lResult

Arguments

(This function has no arguments)

Returns

Returns .T. or .F. whether the internal INET system was successfully initialized

Description

Activates inet support; mainly used for winsock start up at the moment, but could be used in the future for many other purpose. Put it at the beginning of every program using INET functions.

Compliance

Harbour

hb_inetGetSndBufSize()

HB_INETGETSNDBUFSIZE()

Get the socket send buffer size

Syntax

      HB_INETGETSNDBUFSIZE( <socket> ) -> nResult

Arguments

<socket> a socket previously created / opened

Returns

Returns the socket send buffer size or -1 if the socket is closed or an error occurs

Description

Returns the socket send buffer size or -1 if the socket is closed or an error occurs

Compliance

Harbour

hb_inetGetRcvBufSize()

HB_INETGETRCVBUFSIZE()

Get the socket receive buffer size

Syntax

      HB_INETGETRCVBUFSIZE( <socket> ) -> nResult

Arguments

<socket> a socket previously created / opened

Returns

Returns the socket receive buffer size or -1 if the socket is closed or an error occurs

Description

Returns the socket receive buffer size or -1 if the socket is closed or an error occurs

Compliance

Harbour

hb_inetGetHosts()

HB_INETGETHOSTS()

Get an array of IP addresses of a host

Syntax

      HB_INETGETHOSTS( <cName> ) -> aHosts

Arguments

<cName>

Returns

An array of IP addresses

Description

Returns an array containing all the IP addresses associated with a given host name. The IP addressess returned by this funtion are strings in quad dot notations, eg “192.168.1.1”, and can be directly used into hb_InetConnectIP().

cName can be any string: valid DNS names (eg. “www.myserver.com”), locally available names (e.g. “localhost” or windows Network Neighborhood names), or even IP addresses in quad dot notation.

NOTE: This function is not thread safe (by design), and programmers must be sure not to use it at the same time in two different threads, or not to use it together with a hb_InetConnect(). If this kind of situation should ever arise, you are advised to use a thread MUTEX.

On error, and if the server can’t be found, the function returns NIL.

Compliance

Harbour