lwIP 2.1.2 Lightweight IP stack

Macros | Enumerations | Functions
Common functions
APIs » Sequential-style APIs » Netconn API

## Macros
#define | netconn_new(t) netconn_new_with_proto_and_callback(t, 0, NULL)
#define | netconn_peer(c, i, p) netconn_getaddr(c,i,p,0)
#define | netconn_addr(c, i, p) netconn_getaddr(c,i,p,1)
#define | netconn_set_ipv6only(conn, val)
#define | netconn_get_ipv6only(conn) (((conn)->flags & NETCONN_FLAG_IPV6_V6ONLY) != 0)

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

## Functions
err_t | netconn_prepare_delete (struct netconn *conn)
err_t | netconn_delete (struct netconn *conn)
err_t | netconn_bind (struct netconn *conn, const ip_addr_t *addr, u16_t port)
err_t | netconn_bind_if (struct netconn *conn, u8_t if_idx)
err_t | netconn_connect (struct netconn *conn, const ip_addr_t *addr, u16_t port)
err_t | netconn_recv (struct netconn *conn, struct netbuf **new_buf)
err_t | netconn_err (struct netconn *conn)
err_t | netconn_gethostbyname_addrtype (const char *name, ip_addr_t *addr, u8_t dns_addrtype)

## Detailed Description

For use with TCP and UDP

## Macro Definition Documentation

## ◆ netconn_addr

#define netconn_addr | ( |  | c,
|  |  | i,
|  |  | p
| ) |  | netconn_getaddr(c,i,p,1)

## ◆ netconn_get_ipv6only

#define netconn_get_ipv6only | ( |  | conn | ) | (((conn)->flags & NETCONN_FLAG_IPV6_V6ONLY) != 0)

TCP: Get the IPv6 ONLY status of netconn calls (see NETCONN_FLAG_IPV6_V6ONLY)

## ◆ netconn_new

#define netconn_new | ( |  | t | ) | netconn_new_with_proto_and_callback(t, 0, NULL)

Create new netconn connection

Parameters

  t | netconn_type

## ◆ netconn_peer

#define netconn_peer | ( |  | c,
|  |  | i,
|  |  | p
| ) |  | netconn_getaddr(c,i,p,0)

## ◆ netconn_set_ipv6only

#define netconn_set_ipv6only | ( |  | conn,
|  |  | val
| ) |  |

Value:
do { if(val) { \
netconn_set_flags(conn, NETCONN_FLAG_IPV6_V6ONLY); \
} else { \
netconn_clear_flags(conn, NETCONN_FLAG_IPV6_V6ONLY); }} while(0)
NETCONN_FLAG_IPV6_V6ONLY
#define NETCONN_FLAG_IPV6_V6ONLY
Definition: api.h:87

TCP: Set the IPv6 ONLY status of netconn calls (see NETCONN_FLAG_IPV6_V6ONLY)

## Enumeration Type Documentation

## ◆ netconn_type

enum netconn_type

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

## Function Documentation

## ◆ netconn_bind()

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

  conn | the netconn to bind
  addr | the local IP address to bind the netconn to (use IP4_ADDR_ANY/IP6_ADDR_ANY to bind to all addresses)
  port | the local port to bind the netconn to (not used for RAW)

Returns
  ERR_OK if bound, any other err_t on failure

## ◆ netconn_bind_if()

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

  conn | the netconn to bind
  if_idx | the local interface index to bind the netconn to

Returns
  ERR_OK if bound, any other err_t on failure

## ◆ netconn_connect()

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

  conn | the netconn to connect
  addr | the remote IP address to connect to
  port | the remote port to connect to (no used for RAW)

Returns
  ERR_OK if connected, return value of tcp_/udp_/raw_connect otherwise

## ◆ netconn_delete()

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

  conn | the netconn to delete

Returns
  ERR_OK if the connection was deleted

## ◆ netconn_err()

err_t netconn_err | ( | struct netconn * | conn | ) |

Get and reset pending error on a netconn

Parameters

  conn | the netconn to get the error from

Returns
  and pending error or ERR_OK if no error was pending

## ◆ netconn_gethostbyname_addrtype()

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

Execute a DNS query, only one IP address is returned

Parameters

  name | a string representation of the DNS host name to query
  addr | a preallocated ip_addr_t where to store the resolved IP address
  dns_addrtype | IP 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

## ◆ netconn_prepare_delete()

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

  conn | the netconn to delete

Returns
  ERR_OK if the connection was deleted

## ◆ netconn_recv()

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

  conn | the netconn from which to receive data
  new_buf | pointer 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)