The friendly Operating System for the Internet of Things

Connection submodule for TCP connections. More...

Detailed Description

Deprecated:
Please use TCP sock API instead

Files

file  conn/tcp.h
 TCP connection definitions.
 

Typedefs

typedef struct conn_tcp conn_tcp_t
 Implementation-specific type of a TCP connection object.
 

Functions

int conn_tcp_create (conn_tcp_t *conn, const void *addr, size_t addr_len, int family, uint16_t port)
 Creates a new TCP connection object. More...
 
void conn_tcp_close (conn_tcp_t *conn)
 Closes a TCP connection. More...
 
int conn_tcp_getlocaladdr (conn_tcp_t *conn, void *addr, uint16_t *port)
 Gets the local address of a TCP connection. More...
 
int conn_tcp_getpeeraddr (conn_tcp_t *conn, void *addr, uint16_t *port)
 Gets the address of the connected peer of a TCP connection. More...
 
int conn_tcp_connect (conn_tcp_t *conn, const void *addr, size_t addr_len, uint16_t port)
 Connects to a remote TCP peer. More...
 
int conn_tcp_listen (conn_tcp_t *conn, int queue_len)
 Marks connection to listen for a connection request by a remote TCP peer. More...
 
int conn_tcp_accept (conn_tcp_t *conn, conn_tcp_t *out_conn)
 Receives and handles TCP connection requests from other peers. More...
 
int conn_tcp_recv (conn_tcp_t *conn, void *data, size_t max_len)
 Receives a TCP message. More...
 
int conn_tcp_send (conn_tcp_t *conn, const void *data, size_t len)
 Sends a TCP message. More...
 

Function Documentation

int conn_tcp_accept ( conn_tcp_t conn,
conn_tcp_t out_conn 
)
Parameters
[in]connA TCP connection object.
[out]out_connA new TCP connection object for the established connection.
Returns
0 on success.
any other negative number in case of an error. For portability implementations should draw inspiration of the errno values from the POSIX' accept() function specification.
void conn_tcp_close ( conn_tcp_t conn)
Parameters
[in,out]connA TCP connection object.
int conn_tcp_connect ( conn_tcp_t conn,
const void *  addr,
size_t  addr_len,
uint16_t  port 
)
Parameters
[in]connA TCP connection object.
[in]addrThe remote network layer address for conn.
[in]addr_lenLength of addr.
[in]portThe remote TCP port for conn.
Returns
0 on success.
any other negative number in case of an error. For portability implementations should draw inspiration of the errno values from the POSIX' connect() function specification.
int conn_tcp_create ( conn_tcp_t conn,
const void *  addr,
size_t  addr_len,
int  family,
uint16_t  port 
)
Parameters
[out]connPreallocated connection object. Must fill the size of the stack-specific connection desriptor.
[in]addrThe local network layer address for conn.
[in]addr_lenThe length of addr. Must be fitting for the family.
[in]familyThe family of addr (see UNIX address families).
[in]portThe local TCP port for conn.
Returns
0 on success.
any other negative number in case of an error. For portability implementations should draw inspiration of the errno values from the POSIX' bind() function specification.
int conn_tcp_getlocaladdr ( conn_tcp_t conn,
void *  addr,
uint16_t *  port 
)
Parameters
[in]connA TCP connection object.
[out]addrThe local network layer address. Must have space for any address of the connection's family.
[out]portThe local TCP port.
Returns
length of addr on success.
any other negative number in case of an error. For portability implementations should draw inspiration of the errno values from the POSIX' getsockname() function specification.
int conn_tcp_getpeeraddr ( conn_tcp_t conn,
void *  addr,
uint16_t *  port 
)
Parameters
[in]connA TCP connection object.
[out]addrThe network layer address of the connected peer. Must have space for any address of the connection's family.
[out]portThe TCP port of the connected peer.
Returns
length of addr on success.
any other negative number in case of an error. For portability implementations should draw inspiration of the errno values from the POSIX' getpeername() function specification.
int conn_tcp_listen ( conn_tcp_t conn,
int  queue_len 
)
Parameters
[in]connA TCP connection object.
[in]queue_lenMaximum length of the queue for connection requests. An implementation may choose to silently adapt this value to its needs (setting it to a minimum or maximum value). Any negative number must be set at least to 0.
Returns
0 on success.
any other negative number in case of an error. For portability implementations should draw inspiration of the errno values from the POSIX' listen() function specification.
int conn_tcp_recv ( conn_tcp_t conn,
void *  data,
size_t  max_len 
)
Parameters
[in]connA TCP connection object.
[out]dataPointer where the received data should be stored.
[in]max_lenMaximum space available at data.
Note
Function may block.
Returns
The number of bytes received on success.
0, if no received data is available, but everything is in order.
any other negative number in case of an error. For portability, implementations should draw inspiration of the errno values from the POSIX' recv(), recvfrom(), or recvmsg() function specification.
int conn_tcp_send ( conn_tcp_t conn,
const void *  data,
size_t  len 
)
Parameters
[in]connA TCP connection object.
[in]dataPointer where the received data should be stored.
[in]lenMaximum space available at data.
Note
Function may block.
Returns
The number of bytes send on success.
any other negative number in case of an error. For portability, implementations should draw inspiration of the errno values from the POSIX' send(), sendfrom(), or sendmsg() function specification.