Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Common functions

Common functions
[Netconn API]

For use with TCP and UDP. More...

Enumerations

enum  netconn_type { ,
  NETCONN_TCP = 0x10, NETCONN_TCP_IPV6 = NETCONN_TCP | NETCONN_TYPE_IPV6, NETCONN_UDP = 0x20, NETCONN_UDPLITE = 0x21,
  NETCONN_UDPNOCHKSUM = 0x22, NETCONN_UDP_IPV6 = NETCONN_UDP | NETCONN_TYPE_IPV6, NETCONN_UDPLITE_IPV6 = NETCONN_UDPLITE | NETCONN_TYPE_IPV6, NETCONN_UDPNOCHKSUM_IPV6 = NETCONN_UDPNOCHKSUM | NETCONN_TYPE_IPV6,
  NETCONN_RAW
}
 

Protocol family and type of the netconn.

More...

Functions

err_t netconn_prepare_delete (struct netconn *conn)
 Close a netconn 'connection' and free all its resources but not the netconn itself.
err_t netconn_delete (struct netconn *conn)
 Close a netconn 'connection' and free its resources.
err_t netconn_bind (struct netconn *conn, const ip_addr_t *addr, u16_t port)
 Bind a netconn to a specific local IP address and port.
err_t netconn_bind_if (struct netconn *conn, u8_t if_idx)
 Bind a netconn to a specific interface and port.
err_t netconn_connect (struct netconn *conn, const ip_addr_t *addr, u16_t port)
 Connect a netconn to a specific remote IP address and port.
static err_t netconn_recv_data (struct netconn *conn, void **new_buf, u8_t apiflags)
 Receive data: actual implementation that doesn't care whether pbuf or netbuf is received (this is internal, it's just here for describing common errors)
err_t netconn_recv (struct netconn *conn, struct netbuf **new_buf)
 Receive data (in form of a netbuf containing a packet buffer) from a netconn.
err_t netconn_err (struct netconn *conn)
 Get and reset pending error on a netconn.
err_t netconn_gethostbyname_addrtype (const char *name, ip_addr_t *addr, u8_t dns_addrtype) err_t netconn_gethostbyname(const char *name
 Execute a DNS query, only one IP address is returned.

Detailed Description

For use with TCP and UDP.


Enumeration Type Documentation

Protocol family and type of the netconn.

Enumerator:
NETCONN_TCP 

TCP IPv4.

NETCONN_TCP_IPV6 

TCP IPv6.

NETCONN_UDP 

UDP IPv4.

NETCONN_UDPLITE 

UDP IPv4 lite.

NETCONN_UDPNOCHKSUM 

UDP IPv4 no checksum.

NETCONN_UDP_IPV6 

UDP IPv6 (dual-stack by default, unless you call netconn_set_ipv6only)

NETCONN_UDPLITE_IPV6 

UDP IPv6 lite (dual-stack by default, unless you call netconn_set_ipv6only)

NETCONN_UDPNOCHKSUM_IPV6 

UDP IPv6 no checksum (dual-stack by default, unless you call netconn_set_ipv6only)

NETCONN_RAW 

Raw connection IPv4.

Definition at line 113 of file api.h.


Function Documentation

err_t netconn_bind ( struct netconn conn,
const ip_addr_t addr,
u16_t  port 
)

Bind a netconn to a specific local IP address and port.

Binding one netconn twice might not always be checked correctly!

Parameters:
connthe netconn to bind
addrthe local IP address to bind the netconn to (use IP4_ADDR_ANY/IP6_ADDR_ANY to bind to all addresses)
portthe local port to bind the netconn to (not used for RAW)
Returns:
ERR_OK if bound, any other err_t on failure

Definition at line 314 of file lwip_api_lib.c.

err_t netconn_bind_if ( struct netconn conn,
u8_t  if_idx 
)

Bind a netconn to a specific interface and port.

Binding one netconn twice might not always be checked correctly!

Parameters:
connthe netconn to bind
if_idxthe local interface index to bind the netconn to
Returns:
ERR_OK if bound, any other err_t on failure

Definition at line 358 of file lwip_api_lib.c.

err_t netconn_connect ( struct netconn conn,
const ip_addr_t addr,
u16_t  port 
)

Connect a netconn to a specific remote IP address and port.

Parameters:
connthe netconn to connect
addrthe remote IP address to connect to
portthe remote port to connect to (no used for RAW)
Returns:
ERR_OK if connected, return value of tcp_/udp_/raw_connect otherwise

Definition at line 384 of file lwip_api_lib.c.

err_t netconn_delete ( struct netconn conn )

Close a netconn 'connection' and free its resources.

UDP and RAW connection are completely closed, TCP pcbs might still be in a waitstate after this returns.

Parameters:
connthe netconn to delete
Returns:
ERR_OK if the connection was deleted

Definition at line 240 of file lwip_api_lib.c.

err_t netconn_err ( struct netconn conn )

Get and reset pending error on a netconn.

Parameters:
connthe netconn to get the error from
Returns:
and pending error or ERR_OK if no error was pending

Definition at line 1146 of file lwip_api_lib.c.

err_t netconn_gethostbyname_addrtype ( const char *  name,
ip_addr_t addr,
u8_t  dns_addrtype 
) const

Execute a DNS query, only one IP address is returned.

Parameters:
namea string representation of the DNS host name to query
addra preallocated ip_addr_t where to store the resolved IP address
dns_addrtypeIP address type (IPv4 / IPv6)
Returns:
ERR_OK: resolving succeeded ERR_MEM: memory error, try again later ERR_ARG: dns client not initialized or invalid hostname ERR_VAL: dns server response was invalid
err_t netconn_prepare_delete ( struct netconn conn )

Close a netconn 'connection' and free all its resources but not the netconn itself.

UDP and RAW connection are completely closed, TCP pcbs might still be in a waitstate after this returns.

Parameters:
connthe netconn to delete
Returns:
ERR_OK if the connection was deleted

Definition at line 199 of file lwip_api_lib.c.

err_t netconn_recv ( struct netconn conn,
struct netbuf **  new_buf 
)

Receive data (in form of a netbuf containing a packet buffer) from a netconn.

Parameters:
connthe netconn from which to receive data
new_bufpointer where a new netbuf is stored when received data
Returns:
ERR_OK if data has been received, an error code otherwise (timeout, memory error or another error)

Definition at line 867 of file lwip_api_lib.c.

static err_t netconn_recv_data ( struct netconn conn,
void **  new_buf,
u8_t  apiflags 
) [static]

Receive data: actual implementation that doesn't care whether pbuf or netbuf is received (this is internal, it's just here for describing common errors)

Parameters:
connthe netconn from which to receive data
new_bufpointer where a new pbuf/netbuf is stored when received data
apiflagsflags that control function behaviour. For now only:

  • NETCONN_DONTBLOCK: only read data that is available now, don't wait for more data
Returns:
ERR_OK if data has been received, an error code otherwise (timeout, memory error or another error) ERR_CONN if not connected ERR_CLSD if TCP connection has been closed ERR_WOULDBLOCK if the netconn is nonblocking but would block to wait for data ERR_TIMEOUT if the netconn has a receive timeout and no data was received

Definition at line 586 of file lwip_api_lib.c.