You can use the netconn_set_recvtimeout
function to set the timeout in the listening socket to something small, such as 1 ms.
Eg. (Error handling terminated, binding, ease of listening)
struct netconn *conn = netconn_new(NETCONN_TCP); if (conn) { if (netconn_bind(conn, IP_ADDR_ANY, 1025) != ERR_OK) { return; } if (netconn_listen(conn) != ERR_OK) { return; } netconn_set_recvtimeout(conn, 1); }
Then, calls for acceptance delay a maximum of 1 ms:
struct netconn *newConn; err_t result = netconn_accept(conn, &newConn); if (result == ERR_OK) {
source share