nettobac  0.0.0
Network features for FreeBASIC code
n2bConnection Class Reference

The connections class, providing nPut / nGet More...

Collaboration diagram for n2bConnection:

Public Member Functions

 n2bConnection (BYVAL_AS_LONG, BYVAL_AS_ZSTRING_PTR_PTR)
 Create a connection. More...
 
 ~n2bConnection ()
 Finish a connection. More...
 
FUNCTION_AS_INTEGER nPut (BYVAL_AS_STRING, BYVAL_AS_USHORT)
 Send a STRING over socket. More...
 
FUNCTION_AS_INTEGER nPut (BYVAL_AS_ANY_PTR, BYVAL_AS_INTEGER, BYVAL_AS_USHORT)
 Send any data over socket. More...
 
FUNCTION_AS_CONST_ZSTRING_CONST_PTR nGet (BYREF_AS_STRING, BYVAL_AS_USHORT)
 Receive data form socket. More...
 

Public Attributes

ZSTRING_PTR_PTR Errr
 

Protected Attributes

LONG Sock
 The socket number. More...
 
fd_set FdsR
 File descriptor for read. More...
 
fd_set FdsW
 File descriptor for write. More...
 
timeval Timeout
 How long should we wait until network is ready. More...
 

Detailed Description

The connections class, providing nPut / nGet

Do not create this class directly. It has to be constructed with a nettobacServer::nOpen() or a nettobacClient::nOpen() call. Data can get send or received to/from the peer with it.

See section n2bConnection for a list of possible error messages.

Since
0.0.0

Definition at line 25 of file nettobac.bi.

Constructor & Destructor Documentation

n2bConnection::n2bConnection ( BYVAL_AS_LONG  Socket,
BYVAL_AS_ZSTRING_PTR_PTR  Ep 
)

Create a connection.

Parameters
Socketthe socket to use
Epthe pointer for error messages

This constructor checks the socket and sets some options for fast access.

Since
0.0.0

Definition at line 24 of file nettobac.bas.

n2bConnection::~n2bConnection ( )

Finish a connection.

This destructor closes the open socket, if any.

Since
0.0.0

Definition at line 39 of file nettobac.bas.

Member Function Documentation

FUNCTION_AS_INTEGER n2bConnection::nPut ( BYVAL_AS_STRING  Dat,
BYVAL_AS_USHORT  ReTry = 100 
)

Send a STRING over socket.

Parameters
Datthe data to send
ReTrythe number of re-tries when socket isn't ready
Returns
the number of bytes sent (-1 in case of error)

This function sends a STRING variable to the peer, sending all bytes from parameter Dat.

The function waits until the socket is ready to send. The maximum waiting time can get specified by parameter ReTry in steps of 1 / 50 seconds.

Note
ReTry = 0 specifies a single shot.
Since
0.0.0

Definition at line 61 of file nettobac.bas.

Here is the caller graph for this function:

FUNCTION_AS_INTEGER n2bConnection::nPut ( BYVAL_AS_ANY_PTR  Dat,
BYVAL_AS_INTEGER  Az,
BYVAL_AS_USHORT  ReTry = 100 
)

Send any data over socket.

Parameters
Data pointer to the data in memory
Azthe number of bytes to send
ReTrythe number of re-tries when socket isn't ready
Returns
the number of bytes sent (-1 in case of error)

This function sends data to the peer, reading Az number of bytes from the buffer Dat.

The function waits until the socket is ready to send. The maximum waiting time can get specified by parameter ReTry in steps of 1 / 50 seconds.

Note
ReTry = 0 specifies a single shot.
Since
0.0.0

Definition at line 83 of file nettobac.bas.

FUNCTION_AS_CONST_ZSTRING_CONST_PTR n2bConnection::nGet ( BYREF_AS_STRING  Res,
BYVAL_AS_USHORT  ReTry = 100 
)

Receive data form socket.

Parameters
ResThe STRING variable to append the downloaded bytes
ReTryA counter to limit the number of re-tries
Returns
0 (zero) on success, an error message otherwise

This function receives data from the peer. The incomming bytes get appended to the result variable Res.

The function waits until the socket is ready to send before each chunk of data (1024 bytes). The waiting time can get limited by parameter ReTry in steps of 1 / 50 seconds.

Note
The maximum waiting time depend on the value of ReTry and the number of chunks to send.
ReTry = 0 specifies a single shot.
Since
0.0.0

Definition at line 124 of file nettobac.bas.

Here is the caller graph for this function:

Member Data Documentation

ZSTRING_PTR_PTR n2bConnection::Errr

Definition at line 32 of file nettobac.bi.

LONG n2bConnection::Sock
protected

The socket number.

Definition at line 35 of file nettobac.bi.

fd_set n2bConnection::FdsR
protected

File descriptor for read.

Definition at line 37 of file nettobac.bi.

fd_set n2bConnection::FdsW
protected

File descriptor for write.

Definition at line 37 of file nettobac.bi.

timeval n2bConnection::Timeout
protected

How long should we wait until network is ready.

Definition at line 40 of file nettobac.bi.


The documentation for this class was generated from the following files: