Hello again.

I had a look at the points you mentioned to me:

First of all, I have checked that MSG_DONTWAIT in the flags to the recv 
operation, and O_NONBLOCK to the socket options are both set to zero. In 
fact, both flag fields are completely zero. So that the socket should be 
blocking, am I right?

>Take a look at the lwip_recvfrom() function.  Can you check the following 
when you call it by adding some extra debugging:
> - that sock->lastdata is NULL.
OK, it is null

> - that buf returned by netconn_recv() is NULL.
It is null too.

>If that is the case, take a look at netconn_recv().  This can return NULL 
for all sorts of reasons.  Add debugging (e.g. a printf) to each one and 
>see which case is failing.

Next, I specify the failing case, which shows the reason for which the 
function returns NULL.

struct netbuf *
netconn_recv(struct netconn *conn)
{

...
 
  if (conn == NULL) {
    return NULL;
  }
 
  if (conn->recvmbox == SYS_MBOX_NULL) {
    conn->err = ERR_CONN;
    return NULL;
  }

  if (conn->err != ERR_OK) {
    return NULL;
  }

  if (conn->type == NETCONN_TCP) {
    if (conn->pcb.tcp->state == LISTEN) {
      conn->err = ERR_CONN;
      return NULL;
    }

    buf = memp_malloc(MEMP_NETBUF);

    if (buf == NULL) {
      conn->err = ERR_MEM;
      return NULL;
    }
 
    sys_mbox_fetch(conn->recvmbox, (void **)&p);

    if (p != NULL)
    {
        len = p->tot_len;
        conn->recv_avail -= len;
    }
    else <<<<<<<<<<<<<<<<<<<<<<<<< IT GETS INTO THIS ELSE
        len = 0;
            printf("\n Entra en el ELSE, Chkp1\n");
 
    /* Register event with callback */
      if (conn->callback)
        (*conn->callback)(conn, NETCONN_EVT_RCVMINUS, len);
            printf("\n Entra en el Callback, Chkp2\n");

    /* If we are closed, we indicate that we no longer wish to receive
       data by setting conn->recvmbox to SYS_MBOX_NULL. */
    if (p == NULL) { <<<<<<<<<<<<<<<<<<<<<<<<< IT GOES INTO THIS IF 
(p==NULL)
      memp_free(MEMP_NETBUF, buf);
      sys_mbox_free(conn->recvmbox);
      conn->recvmbox = SYS_MBOX_NULL;
      return NULL; <<<<<<<<<<<<<<<<<<<<<<<<< RETURNS NULL
    }

....
....
....

  return buf;
}

The problem seems to be that it is receiving that null p. I would thank 
any advice.

Thank you very much for your help and for using your time for this 
purpose.

Best regards,

Borja.
_______________________________________________
lwip-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to