Barracuda Application Server C/C++ Reference
NO
|
Socket Library.
The Socket Example Lib (selib.h/selib.c) is a basic module that provides a platform agnostic socket API.
Macros | |
#define | INFINITE_TMO (~((U32)0)) |
Infinite wait time option for socket read functions. | |
#define | SOCKET int |
The SOCKET object/handle is an 'int' when using a BSD compatible TCP/IP stack. More... | |
Functions | |
int | se_connect (SOCKET *sock, const char *address, U16 port) |
Initializes a SOCKET object connected to a remote host/address at a given port. More... | |
int | se_bind (SOCKET *sock, U16 port) |
Initializes a SOCKET object bound to a local port, ready to accept client connections. More... | |
int | se_accept (SOCKET **listenSock, U32 timeout, SOCKET **outSock) |
Waits for remote connections on the server SOCKET object 'listenSock', initialized by function se_bind, and initializes socket object 'outSock' to represent the new connection. More... | |
void | se_close (SOCKET *sock) |
Close a connected socket connection. | |
int | se_sockValid (SOCKET *sock) |
Returns TRUE if socket is valid (connected). | |
S32 | se_send (SOCKET *sock, const void *buf, U32 len) |
Sends data to the connected peer. | |
S32 | se_recv (SOCKET *sock, void *buf, U32 len, U32 timeout) |
Waits for data sent by peer. More... | |
void | mainTask (SeCtx *ctx) |
Main entry for all example programs. | |
#define SOCKET int |
The SOCKET object/handle is an 'int' when using a BSD compatible TCP/IP stack.
Non BSD compatible TCP IP stacks must set the macro NO_BSD_SOCK and define the SOCKET object. See the header file selib.h for details.
Waits for remote connections on the server SOCKET object 'listenSock', initialized by function se_bind, and initializes socket object 'outSock' to represent the new connection.
1
Success 0
timeout -1
error int se_bind | ( | SOCKET * | sock, |
U16 | port | ||
) |
Initializes a SOCKET object bound to a local port, ready to accept client connections.
-1
Cannot create socket: Fatal -2
Cannot listen: Fatal -3
Cannot bind: socket in use int se_connect | ( | SOCKET * | sock, |
const char * | address, | ||
U16 | port | ||
) |
Initializes a SOCKET object connected to a remote host/address at a given port.
-1
Cannot create socket: Fatal -2
Cannot resolve 'address' -3
Cannot connect S32 se_recv | ( | SOCKET * | sock, |
void * | buf, | ||
U32 | len, | ||
U32 | timeout | ||
) |
Waits for data sent by peer.
sock | the SOCKET object. |
buf | is the data to send. |
len | is the 'buf' length. |
timeout | in milliseconds. The timeout can be set to INFINITE_TMO. |