int8_t AsyncServer::_accept(tcp_pcb* pcb, int8_t err){ tcp_accepted(_pcb); if(_connect_cb){ if (_noDelay) tcp_nagle_disable(pcb); else tcp_nagle_enable(pcb); AsyncClient *c = new AsyncClient(pcb); if(c){ _in_lwip_thread = true; c->_in_lwip_thread = true; _connect_cb(_connect_cb_arg, c); c->_in_lwip_thread = false; _in_lwip_thread = false; return ERR_OK; } } if(tcp_close(pcb) != ERR_OK){ tcp_abort(pcb); } log_e("FAIL"); return ERR_OK; }
int8_t AsyncClient::_connected(void* pcb, int8_t err){ _pcb = reinterpret_cast<tcp_pcb*>(pcb); if(_pcb){ tcp_setprio(_pcb, TCP_PRIO_MIN); tcp_recv(_pcb, (tcp_recv_fn) &_s_recv); tcp_sent(_pcb, &_s_sent); tcp_poll(_pcb, &_s_poll, 1); _pcb_busy = false; } if(_connect_cb) _connect_cb(_connect_cb_arg, this); return ERR_OK; }
int8_t AsyncClient::_connected(void* pcb, int8_t err){ _pcb = reinterpret_cast<tcp_pcb*>(pcb); if(_pcb){ _rx_last_packet = millis(); _pcb_busy = false; tcp_recv(_pcb, &_tcp_recv); tcp_sent(_pcb, &_tcp_sent); tcp_poll(_pcb, &_tcp_poll, 1); } _in_lwip_thread = true; if(_connect_cb) _connect_cb(_connect_cb_arg, this); _in_lwip_thread = false; return ERR_OK; }
int8_t AsyncServer::_accept(tcp_pcb* pcb, int8_t err){ if(_connect_cb) _connect_cb(_connect_cb_arg, new AsyncClient(pcb)); return ERR_OK; }