tcp.h, opt.h, api.h, api_msg.h, tcp.c, tcp_in.c, api_lib.c, api_msg.c, sockets.c, init.c: task #7252: Implement TCP listen backlog: Warning: raw API applications have to call 'tcp_accepted(pcb)' in their accept callback to keep accepting new connections.

This commit is contained in:
goldsimon
2007-12-21 16:47:56 +00:00
parent 48e62e25e9
commit 1ed34774c8
11 changed files with 93 additions and 11 deletions

View File

@@ -179,7 +179,8 @@ err_t netconn_connect (struct netconn *conn,
struct ip_addr *addr,
u16_t port);
err_t netconn_disconnect (struct netconn *conn);
err_t netconn_listen (struct netconn *conn);
err_t netconn_listen_with_backlog(struct netconn *conn, u8_t backlog);
#define netconn_listen(conn) netconn_listen_with_backlog(conn, LWIP_DEFAULT_LISTEN_BACKLOG);
struct netconn * netconn_accept (struct netconn *conn);
struct netbuf * netconn_recv (struct netconn *conn);
err_t netconn_sendto (struct netconn *conn,

View File

@@ -93,6 +93,11 @@ struct api_msg_msg {
enum netconn_igmp join_or_leave;
} jl;
#endif /* LWIP_IGMP */
#if LWIP_LISTEN_BACKLOG
struct {
u8_t backlog;
} lb;
#endif /* LWIP_LISTEN_BACKLOG */
} msg;
};

View File

@@ -728,6 +728,23 @@
#define LWIP_CALLBACK_API 0
#endif
/**
* LWIP_LISTEN_BACKLOG: Enable the backlog option for tcp listen pcb.
*/
#ifndef LWIP_LISTEN_BACKLOG
#define LWIP_LISTEN_BACKLOG 1
#endif
/**
* The maximum allowed backlog for TCP listen netconns.
* This backlog is used unless another is explicitly specified.
* 0xff is the maximum (u8_t).
*/
#ifndef LWIP_DEFAULT_LISTEN_BACKLOG
#define LWIP_DEFAULT_LISTEN_BACKLOG 0xff
#endif
/*
----------------------------------
---------- Pbuf options ----------

View File

@@ -79,6 +79,11 @@ void tcp_err (struct tcp_pcb *pcb,
#define tcp_mss(pcb) ((pcb)->mss)
#define tcp_sndbuf(pcb) ((pcb)->snd_buf)
#if LWIP_LISTEN_BACKLOG
#define tcp_accepted(pcb) (((struct tcp_pcb_listen *)(pcb))->accepts_pending--)
#define tcp_backlog(pcb, bklog) (((struct tcp_pcb_listen *)(pcb))->backlog = bklog)
#endif /* LWIP_LISTEN_BACKLOG */
void tcp_recved (struct tcp_pcb *pcb, u16_t len);
err_t tcp_bind (struct tcp_pcb *pcb, struct ip_addr *ipaddr,
u16_t port);
@@ -412,6 +417,10 @@ struct tcp_pcb_listen {
*/
err_t (* accept)(void *arg, struct tcp_pcb *newpcb, err_t err);
#endif /* LWIP_CALLBACK_API */
#if LWIP_LISTEN_BACKLOG
u8_t backlog;
u8_t accepts_pending;
#endif /* LWIP_LISTEN_BACKLOG */
};
#if LWIP_EVENT_API