include/razorback/socket.h File Reference

Socket API. More...

#include <razorback/visibility.h>
#include <razorback/types.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <openssl/ssl.h>
Include dependency graph for socket.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Socket
 Socket Structure. More...

Functions

SO_PUBLIC struct SocketSocket_Listen (const uint8_t *sourceAddress, uint16_t port)
 Starts a socket listening.
SO_PUBLIC struct SocketSocket_Listen_Unix (const char *path)
 Start a UNIX socket listening.
SO_PUBLIC struct SocketSSL_Socket_Connect (const uint8_t *destinationAddress, uint16_t port)
 Starts a socket listening.
SO_PUBLIC int Socket_Accept (struct Socket **socket, const struct Socket *listeningSocket)
 Starts a socket from a listening socket.
SO_PUBLIC struct SocketSocket_Connect (const uint8_t *destinationAddress, uint16_t port)
 Starts a connecting socket.
SO_PUBLIC void Socket_Close (struct Socket *socket)
 Close a socket.
SO_PUBLIC ssize_t Socket_Tx (const struct Socket *socket, size_t len, const uint8_t *buffer)
 transmits on a socket
SO_PUBLIC PRINTF_FUNC (2, 3) extern bool Socket_Printf(const struct Socket *socket
 Formats a string and transmits it on a socket.
SO_PUBLIC const char SO_PUBLIC
ssize_t 
Socket_Rx (const struct Socket *socket, size_t len, uint8_t *buffer)
 receives on a socket
SO_PUBLIC ssize_t Socket_Rx_Until (const struct Socket *socket, uint8_t **r_buffer, uint8_t terminator)
 receives on a socket until the terminator is reached

Variables

SO_PUBLIC const char * fmt

Detailed Description

Socket API.


Function Documentation

SO_PUBLIC PRINTF_FUNC ( ,
 
) const

Formats a string and transmits it on a socket.

Parameters:
socket the socket to use.
fmt The printf format string
... the format arguments.
Returns:
true on success false on error.
SO_PUBLIC int Socket_Accept ( struct Socket **  socket,
const struct Socket listeningSocket 
)

Starts a socket from a listening socket.

Parameters:
*socket the socket
*listeningSocket the listening socket
Returns:
0 = timeout, -1 = error, 1 = ok
SO_PUBLIC void Socket_Close ( struct Socket socket  ) 

Close a socket.

Parameters:
*socket the socket
SO_PUBLIC struct Socket* Socket_Connect ( const uint8_t *  destinationAddress,
uint16_t  port 
) [read]

Starts a connecting socket.

Parameters:
*destinationAddress the address
port the port
Returns:
a new socket on success null on failure.
SO_PUBLIC struct Socket* Socket_Listen ( const uint8_t *  sourceAddress,
uint16_t  port 
) [read]

Starts a socket listening.

Parameters:
*sourceAddress The address
port The port
Returns:
A new socket or NULL on error.
SO_PUBLIC struct Socket* Socket_Listen_Unix ( const char *  path  )  [read]

Start a UNIX socket listening.

Parameters:
path Path to the socket file
Returns:
A new socket or NULL on error.
SO_PUBLIC const char SO_PUBLIC ssize_t Socket_Rx ( const struct Socket socket,
size_t  len,
uint8_t *  buffer 
)

receives on a socket

Parameters:
*socket the socket
len the size to read
*buffer the data
Returns:
The number of bytes read on success, -1 on error, 0 on socket closed
Type Constraints
SO_PUBLIC ssize_t Socket_Rx_Until ( const struct Socket socket,
uint8_t **  r_buffer,
uint8_t  terminator 
)

receives on a socket until the terminator is reached

Parameters:
socket the socket
r_buffer Buffer with the read data
terminator the terminating character
Returns:
-1 on error, 0 on EOF, len+1 if the terminator was not found, or the amount of data read >0 && <= len if the terminator was found.
SO_PUBLIC ssize_t Socket_Tx ( const struct Socket socket,
size_t  len,
const uint8_t *  buffer 
)

transmits on a socket

Parameters:
*socket the socket
len the size of data
*buffer the data
Returns:
The number of bytes sent on success, -1 on error, 0 on socket closed
SO_PUBLIC struct Socket* SSL_Socket_Connect ( const uint8_t *  destinationAddress,
uint16_t  port 
) [read]

Starts a socket listening.

Parameters:
*destinationAddress The address
port The port
Returns:
A new socket or NULL on error.
 All Data Structures Files Functions Variables Enumerations Enumerator Defines
Generated on Sun Dec 9 04:00:11 2012 for RazorbackAPI by  doxygen 1.6.3