Wiicom API Lib
 Tutto Strutture dati File Funzioni Variabili Ridefinizioni di tipo (typedef) Tipi enumerati (enum) Valori del tipo enumerato Definizioni Gruppi
Riferimenti per il file C:/WIICOM-SVN/Sviluppo/Software/library/wiicom_lib/trunk/wiicom_libsocket.c

Socket function library. Continua...

#include "wiicom_libsocket.h"
#include "wiicom_libutil.h"

Funzioni

uint8_t wiicom_socket_initLibSocket ()
 Function that initializes the socket library
Warning! This function should be called before using the socket. Continua...
 
void wiicom_socket_deinitLibSocket ()
 Function that de-initialize the socket library
Warning! This function is called when not used any more a sockets or, in general, before the close of the program. Continua...
 
void wiicom_socket_set_timeout_conn (uint8_t sec)
 Function that sets the connection timeout of a socket. Continua...
 
void wiicom_socket_set_timeout_reciv (uint8_t sec)
 Funzione che imposta il timeout della ricezione dati di un socket. Continua...
 
uint8_t wiicom_socket_get_timeout_conn ()
 Function that returns the seconds after which there is a timeout in the connection of a socket. Continua...
 
uint8_t wiicom_socket_get_timeout_reciv ()
 Function that returns the seconds after which you have a timeout when receiving data. Continua...
 
void wiicom_socket_set_address (struct sockaddr_in *socket_address, const char *ip, int port)
 Function that set a socket address. Continua...
 
uint8_t wiicom_socket_blocking (int socket_fd, uint8_t b_block)
 Funzione che imposta il socket come bloccante o non bloccante. Continua...
 
int wiicom_socket_create (int domain, int type, int protocol)
 Function that create a socket. Continua...
 
void wiicom_socket_close (int socket_fd)
 Function that close a socket. Continua...
 
int wiicom_socket_connect (int socketToConnect, struct sockaddr_in *socketToConnect_addr)
 Function that make a socket connection with timeout. Continua...
 
int wiicom_socket_sendall (int socket_fd, uint8_t *buf, uint16_t *len)
 Function that sends a data buffer on socket. Continua...
 
ssize_t wiicom_socket_reciv (int socket_fd, void *buffer, size_t buffer_size)
 Function that receives the data transmitted to the socket with timeout On error or timeout the socket is closed. Continua...
 
ssize_t wiicom_socket_notimeout_reciv (int socket_fd, void *buffer, size_t buffer_size)
 Function that receives the data transmitted to the socket without timeout. Continua...
 
uint8_t wiicom_socket_shutdown (int socket_fd)
 Function that shut down a socket. Continua...
 

Descrizione dettagliata

Socket function library.

Generic library for managing socket

Autore
Marco Malano
WIICOM s.r.l
Versione
1.0.0
Data
2012
Attenzione
This library depends on wiicom_libutil
Every function that expects a result, in case of an error, set the Wiicom errno and print to stderr the error occurred.
Nota
None.

Documentazione delle funzioni

uint8_t wiicom_socket_blocking ( int  socket_fd,
uint8_t  b_block 
)

Funzione che imposta il socket come bloccante o non bloccante.

Parametri
[in]socket_fda file descriptor for the socket
[in]b_blockif TRUE sets the socket as a blocker, if FALSE sets it as non-blocking
Restituisce
On success, TRUE is returned, On error, FALSE is returned
void wiicom_socket_close ( int  socket_fd)

Function that close a socket.

Parametri
[in]socket_fda file descriptor for the socket to close
Restituisce
void
int wiicom_socket_connect ( int  socketToConnect,
struct sockaddr_in *  socketToConnect_addr 
)

Function that make a socket connection with timeout.

Parametri
[in]socketToConnecta file descriptor for the socket on which connect
[in]socketToConnect_addrsockaddr_in
Restituisce
On success, 0 is returned, On error, -1 is returned
int wiicom_socket_create ( int  domain,
int  type,
int  protocol 
)

Function that create a socket.

Parametri
[in]domaincommunication domain
[in]typespecifies the communication semantics
[in]protocolspecifies a particular protocol to be used with the socket
Restituisce
on success, a file descriptor for the new socket is returned. On error, -1 is returned
void wiicom_socket_deinitLibSocket ( )

Function that de-initialize the socket library
Warning! This function is called when not used any more a sockets or, in general, before the close of the program.

Restituisce
void
uint8_t wiicom_socket_get_timeout_conn ( )

Function that returns the seconds after which there is a timeout in the connection of a socket.

Restituisce
Timeout in seconds
uint8_t wiicom_socket_get_timeout_reciv ( )

Function that returns the seconds after which you have a timeout when receiving data.

Restituisce
Timeout in seconds
uint8_t wiicom_socket_initLibSocket ( )

Function that initializes the socket library
Warning! This function should be called before using the socket.

Restituisce
On success, TRUE is returned, On error, FALSE is returned
ssize_t wiicom_socket_notimeout_reciv ( int  socket_fd,
void *  buffer,
size_t  buffer_size 
)

Function that receives the data transmitted to the socket without timeout.

Parametri
[in]socket_fda file descriptor for the socket where datas are recived
[out]bufferbuffer in which datas are loaded
[in]buffer_sizesize of the buffer containing the data read
Restituisce
On success, number of bytes received. 0 is returned if the socket has been closed. On error, -1 is returned
ssize_t wiicom_socket_reciv ( int  socket_fd,
void *  buffer,
size_t  buffer_size 
)

Function that receives the data transmitted to the socket with timeout On error or timeout the socket is closed.

Parametri
[in]socket_fda file descriptor for the socket where datas are recived
[out]bufferit contains data to send
[in]buffer_sizesize of the buffer to send
Restituisce
On success, number of bytes transmitted. 0 is returned if the socket has been closed. On error, -1 is returned
int wiicom_socket_sendall ( int  socket_fd,
uint8_t *  buf,
uint16_t *  len 
)

Function that sends a data buffer on socket.

Parametri
[in]socket_fda file descriptor for the socket where datas are send
[in]bufa datas to send
[in,out]lennumber of bytes in the buffer to be sent, after sending it contains the number of bytes sent
Restituisce
On success, 0 is returned. On error, -1 is returned
void wiicom_socket_set_address ( struct sockaddr_in *  socket_address,
const char *  ip,
int  port 
)

Function that set a socket address.

Parametri
[out]socket_addresssocket_address to set
[in]ipIP address
[in]portPort
Restituisce
void
void wiicom_socket_set_timeout_conn ( uint8_t  sec)

Function that sets the connection timeout of a socket.

Parametri
[in]secnumber of seconds
Restituisce
void
void wiicom_socket_set_timeout_reciv ( uint8_t  sec)

Funzione che imposta il timeout della ricezione dati di un socket.

Parametri
[in]secnumber of seconds
Restituisce
void
uint8_t wiicom_socket_shutdown ( int  socket_fd)

Function that shut down a socket.

Parametri
[in]socket_fda file descriptor for the socket to close
Restituisce
On success, TRUE is returned, On error, FALSE is returned