Main Page | Class List | File List | Class Members | File Members | Related Pages

BTAPI.h File Reference

Declares the classes/structures and functions in the BTAPI. More...

#include <udt.h>
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>

Classes

struct  X_STATS
 X_STATS Structure storing socket statistics. More...
class  X_SOCKET
 X_SOCKET - The class responsible for storing socket information. More...

Defines

#define X_ERROR   -1
#define X_SUCCESS   0
#define X_READABLE   4
#define X_WRITABLE   2
#define X_EXCEPTION   1

Enumerations

enum  X_SOCKET_ERRORS {
  X_NOERROR, X_BADTYPE, X_IMPL, X_MALLOC_ERROR,
  X_BADSOCK, X_TIMEOUT, X_REFUSED, X_NOCONN,
  X_NOBIND, X_BADADDR, X_NOLISTEN, X_NOACCEPT,
  X_NOTSTREAM, X_WOULDBLOCK, X_BADOPT, X_BADFD,
  X_INVAL, X_UNCONN, X_UNKNOWN
}
enum  X_SOCKET_OPTIONS {
  SNDSIZE, NOPMTUD, NONBLOCK, QTTL,
  MTU, MSGSIZE, AVGPKTSIZE
}

Functions

X_SOCKETsocket_ok (X_SOCKET *pskt)
 To check if pskt is X_SOCKET_FAILED or pskt is infested with errors.
X_SOCKETx_socket (int socktype, X_SOCKET *skt)
 To create a new instance of X_SOCKET.
int x_close (X_SOCKET *skt)
 To close X_SOCKET *.
int x_connect (X_SOCKET *skt, const struct sockaddr *addr, int len)
 Connect to a host specified by addr.
int x_bind (X_SOCKET *skt, const struct sockaddr *addr, int len)
 Bind on port specified by addr.
int x_listen (X_SOCKET *skt, int backlog)
 Listen for incoming connections.
X_SOCKETx_accept (X_SOCKET *skt, struct sockaddr *addr, int *len)
 Accept incoming connections.
int x_setsockopt (X_SOCKET *skt, int optname, void *optval, int optlen)
 Set socket options.
int x_getsockopt (X_SOCKET *skt, int optname, void *optval, int *optlen)
 Get socket options.
X_STATSx_sockstats (X_SOCKET *skt)
 Get transfer statistics of skt.
int x_sockerror (X_SOCKET *skt)
 Check error status of skt.
char * x_errortext (int err)
 Get error text corresponding to error number err.
int x_sendfile (X_SOCKET *skt, int fd, off_t offset, size_t size)
 Send file using skt.
int x_send (X_SOCKET *skt, void *buf, size_t len)
 Send data using skt.
int x_recvfile (X_SOCKET *skt, int fd, off_t offset, size_t size)
 Receive file using skt.
int x_recv (X_SOCKET *skt, void *buf, size_t len)
 receive data using skt
int x_selectmark (X_SOCKET *skt, int mark)
 Mark socket for select.
int x_selecttest (X_SOCKET *skt)
 Test select returned socket skt, for mark.
int x_select (int len, X_SOCKET **skts, struct timeval *timeout)
 perform select call to test multiple sockets for I/O

Variables

X_SOCKET LAST_ERROR
X_SOCKETX_SOCKET_FAILED = &LAST_ERROR


Detailed Description

Declares the classes/structures and functions in the BTAPI.


Define Documentation

#define X_ERROR   -1
 

Used to represent error value

#define X_EXCEPTION   1
 

Used in select call to test for exceptions in sockets

#define X_READABLE   4
 

Used in select call to test for sockets ready to read from

#define X_SUCCESS   0
 

Used to represent success value

#define X_WRITABLE   2
 

Used in select call to test for sockets ready to write to


Enumeration Type Documentation

enum X_SOCKET_ERRORS
 

For storing different socket errors

Enumerator:
X_NOERROR 
X_BADTYPE 
X_IMPL 
X_MALLOC_ERROR 
X_BADSOCK 
X_TIMEOUT 
X_REFUSED 
X_NOCONN 
X_NOBIND 
X_BADADDR 
X_NOLISTEN 
X_NOACCEPT 
X_NOTSTREAM 
X_WOULDBLOCK 
X_BADOPT 
X_BADFD 
X_INVAL 
X_UNCONN 
X_UNKNOWN 

enum X_SOCKET_OPTIONS
 

For storing different socket options

Enumerator:
SNDSIZE 
NOPMTUD 
NONBLOCK 
QTTL 
MTU 
MSGSIZE 
AVGPKTSIZE 


Function Documentation

X_SOCKET* socket_ok X_SOCKET pskt  ) 
 

To check if pskt is X_SOCKET_FAILED or pskt is infested with errors.

Parameters:
pskt [in] pointer to X_SOCKET

X_SOCKET* x_accept X_SOCKET skt,
struct sockaddr *  addr,
int *  len
 

Accept incoming connections.

Parameters:
skt [in] pointer to socket to be used for accept
addr [out] sockaddr structure which returns address details of peer
len [in/out] length of addr
Returns:
X_SUCCESS 0 on success and X_ERROR on failure

int x_bind X_SOCKET skt,
const struct sockaddr *  addr,
int  len
 

Bind on port specified by addr.

Parameters:
skt [in] pointer to skt to be used for bind
addr [in] sockaddr structure containing port number and other parameters
len [in] length of addr
Returns:
X_SUCCESS 0 on success and X_ERROR on failure

int x_close X_SOCKET skt  ) 
 

To close X_SOCKET *.

Parameters:
skt pointer to X_SOCKET to be closed
Returns:
X_SUCCESS 0 on success and X_ERROR on failure

int x_connect X_SOCKET skt,
const struct sockaddr *  addr,
int  len
 

Connect to a host specified by addr.

Parameters:
skt pointer to the skt to be used for connect
addr sockaddr structure containing address of host
len length of addr
Returns:
X_SUCCESS 0 on success and X_ERROR on failure

char* x_errortext int  err  ) 
 

Get error text corresponding to error number err.

Parameters:
err [in] error number whose description has to be retreived
Returns:
pointer to cstring with error description

int x_getsockopt X_SOCKET skt,
int  optname,
void *  optval,
int *  optlen
 

Get socket options.

Parameters:
skt [in] pointer to socket whose options are being fetched
optname [in] option from X_SOCKET_OPTIONS
optval [out] value of the option selected
optlen [in/out] size of optval
Returns:
X_SUCCESS 0 on success and X_ERROR on failure

int x_listen X_SOCKET skt,
int  backlog
 

Listen for incoming connections.

Parameters:
skt [in] pointer to socket to be used for listening
backlog [in] max number of connections allowed in queue
Returns:
X_SUCCESS 0 on success and X_ERROR on failure

int x_recv X_SOCKET skt,
void *  buf,
size_t  len
 

receive data using skt

Parameters:
skt [in] pointer to socket to be used for receiving
buf [in] pointer to buffer with data to be received
len [in] size of data buffer buf
Returns:
number of bytes sent

int x_recvfile X_SOCKET skt,
int  fd,
off_t  offset,
size_t  size
 

Receive file using skt.

Parameters:
skt [in] pointer to skt to be used for receiving file
fd [in] file descriptor to the file to be recv
offset [in] offset from the starting of the file
size [in] size of the data to be received
Returns:
number of actual bytes received

int x_select int  len,
X_SOCKET **  skts,
struct timeval *  timeout
 

perform select call to test multiple sockets for I/O

Parameters:
len [in] number of sockets to be selected from
skts [in] pointer to an array of sockets to be selected
Returns:
returns 0 ( X_SUCCESS ) on success and returns -1 (X_ERROR) on failure

int x_selectmark X_SOCKET skt,
int  mark
 

Mark socket for select.

Parameters:
skt [in] pointer to the socket to be marked
mark [in] an integer value between 0 and 7 4 - indicates test for read 2 - indicates test for write 1 - indicates test for exception
Returns:
returns 0 ( X_SUCCESS ) on success and returns -1 (X_ERROR) on failure

int x_selecttest X_SOCKET skt  ) 
 

Test select returned socket skt, for mark.

Parameters:
skt [in] socket to be tested after select
Returns:
returns a bitwise OR of X_WRITABLE X_READABLE and X_EXCEPTION ( stored as mark )

int x_send X_SOCKET skt,
void *  buf,
size_t  len
 

Send data using skt.

Parameters:
skt [in] pointer to socket to be used for sending
buf [in] pointer to buffer with data to be sent
len [in] size of data buffer buf
Returns:
number of bytes sent

int x_sendfile X_SOCKET skt,
int  fd,
off_t  offset,
size_t  size
 

Send file using skt.

Parameters:
skt [in] pointer to skt to be used for sending file
fd [in] file descriptor to the file to be sent
offset [in] offset from the starting of the file
size [in] size of the data to be transferred
Returns:
number of actual bytes transferred

int x_setsockopt X_SOCKET skt,
int  optname,
void *  optval,
int  optlen
 

Set socket options.

Parameters:
skt [in] pointer to socket whose options are being set
optname [in] option from X_SOCKET_OPTIONS
optval [in] value of the option selected
optlen [in] size of optval
Returns:
X_SUCCESS 0 on success and X_ERROR on failure

int x_sockerror X_SOCKET skt  ) 
 

Check error status of skt.

Parameters:
skt [in] pointer to X_SOCKET whose error is to be retrieved
Returns:
error number indicating type of error

X_SOCKET* x_socket int  socktype,
X_SOCKET skt
 

To create a new instance of X_SOCKET.

Parameters:
socktype [in] Type of socket - SOCK_STREAM / SOCK_DGRAM
Returns:
returns pointer to the new X_SOCKET on success or return X_SOCKET_FAILED on failure

X_STATS* x_sockstats X_SOCKET skt  ) 
 

Get transfer statistics of skt.

Parameters:
skt [in] pointer to the socket whose statistics are to be retrieved
Returns:
pointer to the X_STATS instance with the statistics of skt


Variable Documentation

X_SOCKET LAST_ERROR
 

Global X_SOCKET Error Object - Used to store LIBRARY WIDE Socket Errors

X_SOCKET* X_SOCKET_FAILED = &LAST_ERROR
 

Pointer to X_SOCKET LAST_ERROR


Generated on Thu Sep 1 09:07:29 2005 for BTAPI-KR ( Bulk Transport API KR) by  doxygen 1.4.3-20050530