picow-http 1.1.0-2-ga16b87a
HTTP server for the Raspberry Pi PicoW
server_cfg Struct Reference

HTTP server configuration. More...

#include </builds/sysprogs-tutorials/picow_http/include/picow_http/http.h>

Data Fields

struct ntp_cfg ntp_cfg
 
const ip_addr_t * ipaddr
 
unsigned idle_tmo_s
 
unsigned send_tmo_s
 
uint16_t port
 
uint8_t listen_backlog
 
enum lwip_ip_addr_type ip_type
 
bool tls
 

Detailed Description

Configuration of the HTTP server used at startup by http_srv_init().

Struct members ipaddr and ip_type, which configure the IP address at which the server listens, use data types from lwIP for IP address handling. To configure a listen address that differs from the default, use one of the mechanisms defined in lwIP's ip_addr.h, ip4_addr.h and/or ip6_addr.h

For example, to listen only at a specific IPv4 address (perhaps because a static IPv4 address has been configured at the router for the PicoW's MAC address):

#include "lwip/ip4_addr.h"
struct server_cfg cfg;
// Start with the default config, so that we only need to change
// individual fields.
// Listen at 192.0.2.47
IP4_ADDR(cfg.ipaddr, 192, 0, 2, 47);
// Listener is IPv4 only.
cfg.ip_type = IPADDR_TYPE_V4;
if (http_srv_init(&srv, &cfg) != ERR_OK) {
// Error handling
}
static struct server_cfg http_default_cfg(void)
Get the default HTTP server configuration.
Definition: http.h:895
err_t http_srv_init(struct server **server, struct server_cfg *cfg)
Start an HTTP server.
HTTP server configuration.
Definition: http.h:768

A simple and common solution is for the server to listen at any IPv4 or IPv6 address assigned to the PicoW, using IP_ADDR_ANY for the ipaddr member and IPADDR_TYPE_ANY for ip_type. This is the configuration set by http_default_cfg(), so it requires no further modification by application code.

See also
http_srv_init(), http_default_cfg(), http_cfg(), lwIP IP address handling

Field Documentation

◆ idle_tmo_s

unsigned server_cfg::idle_tmo_s

Idle connection timeout in seconds. The timeout begins after the most recent response is sent on an established client connection. If no new request has been received on the connection when the timeout elapses, the connection is closed. Thus this timeout serves to clean up unused connections.

◆ ip_type

enum lwip_ip_addr_type server_cfg::ip_type

Listen at an IPv4 or IPv6 address, or both.

◆ ipaddr

const ip_addr_t* server_cfg::ipaddr

IP address at which the server listens.

◆ listen_backlog

uint8_t server_cfg::listen_backlog

Maximum length of the listen queue for incoming connections.

◆ ntp_cfg

struct ntp_cfg server_cfg::ntp_cfg

Configuration of NTP time synchronization

◆ port

uint16_t server_cfg::port

Port at which the server listens.

◆ send_tmo_s

unsigned server_cfg::send_tmo_s

Network send timeout in seconds.

◆ tls

bool server_cfg::tls

true iff this is the configuration of a TLS server.


The documentation for this struct was generated from the following file: