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

BTAPI.cpp File Reference

Contains the definitions of all the functions comprising the BTAPI. More...

#include <stdio.h>
#include <stdlib.h>
#include "BTAPI.h"
#include <string.h>
#include <sys/mman.h>
#include <iostream>

Functions

int set_last_X_SOCKET_ERROR (X_SOCKET *skt)
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=NULL, int optlen=0)
 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


Detailed Description

Contains the definitions of all the functions comprising the BTAPI.


Function Documentation

int set_last_X_SOCKET_ERROR X_SOCKET skt  ) 
 

sets the X_SOCKET_ERROR to the last library wide error if it is due to a socket Does not validate to check whether this was the socket which caused the error

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


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