int8_t AsyncClient::_close(){
  int8_t err = ERR_OK;
  if(_pcb) {
    err = tcp_close(_pcb);
    if(err != ERR_OK) {
      err = abort();
    }
    if(_discard_cb)
      _discard_cb(_discard_cb_arg, this);
  }
  return err;
}
void AsyncClient::_error(int8_t err) {
  if(_error_cb) {
    _error_cb(_error_cb_arg, this, err);
  }
  if(err){
    if(_pcb) {
      _pcb->state = (tcp_state)0;
    }
    if(_discard_cb) {
      _discard_cb(_discard_cb_arg, this);
    }
  }
}
Esempio n. 3
0
void AsyncClient::_dns_found(ip_addr_t *ipaddr){
    _in_lwip_thread = true;
    if(ipaddr){
        connect(IPAddress(ipaddr->u_addr.ip4.addr), _connect_port);
    } else {
        log_e("dns fail");
        if(_error_cb)
            _error_cb(_error_cb_arg, this, -55);
        if(_discard_cb)
            _discard_cb(_discard_cb_arg, this);
    }
    _in_lwip_thread = false;
}
Esempio n. 4
0
void AsyncClient::_error(int8_t err) {
    if(_pcb){
        tcp_arg(_pcb, NULL);
        tcp_sent(_pcb, NULL);
        tcp_recv(_pcb, NULL);
        tcp_err(_pcb, NULL);
        tcp_poll(_pcb, NULL, 0);
        _pcb = NULL;
    }
    if(_error_cb)
        _error_cb(_error_cb_arg, this, err);
    if(_discard_cb)
        _discard_cb(_discard_cb_arg, this);
}
Esempio n. 5
0
int8_t AsyncClient::_close(){
    int8_t err = ERR_OK;
    if(_pcb) {
        //log_i("");
        tcp_arg(_pcb, NULL);
        tcp_sent(_pcb, NULL);
        tcp_recv(_pcb, NULL);
        tcp_err(_pcb, NULL);
        tcp_poll(_pcb, NULL, 0);
        if(_in_lwip_thread){
            err = tcp_close(_pcb);
        } else {
            err = _tcp_close(_pcb);
        }
        if(err != ERR_OK) {
            err = abort();
        }
        _pcb = NULL;
        if(_discard_cb)
            _discard_cb(_discard_cb_arg, this);
    }
    return err;
}