lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] lwip_accept() blocks for non-blocking sockets ?


From: Jonathan Larmour
Subject: Re: [lwip-users] lwip_accept() blocks for non-blocking sockets ?
Date: Wed, 01 Oct 2008 21:56:46 +0100
User-agent: Mozilla Thunderbird 1.0.8-1.1.fc3.4.legacy (X11/20060515)

address@hidden wrote:
I've noticed this too. It's a relatively easy fix. In api/sockets.c in
lwip_accept, put this:
  if (sock->flags & O_NONBLOCK)
  {
    if (!(sock->lastdata || sock->rcvevent))

I'm not sure I understand why sock->lastdata is relevant?

Jifl


    {
      LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_accept(%"S32_F"): returning
EWOULDBLOCK\n", s));
      sock_set_errno(sock, EWOULDBLOCK);
      return -1;
    }
  }

before this:
  newconn = netconn_accept(sock->conn);

Essentially, I took this from lwip_recvfrom.

John L., you may want to test/commit this too.


Tamas Somogyi wrote:

Hi,

It seems that lwip_accept() blocks the calling thread even if the
listening socket is set to non-blocking mode - see sample code below.
Is it the normal behaviour or a bug?

Normal behaviour. Only non-blocking reads are implemented in lwip.

However lwIP does have receive timeouts, which also affect accepts.
Perhaps
that might be useful. Enable LWIP_SO_RCVTIMEO in lwipopts.h, and do a call
to lwip_setsockopt, e.g.:

int timeout = 1000; /* 1000 msecs */
err = lwip_setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout,
sizeof(timeout));

Jifl
--
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------       Opinions==mine
   >>>> Visit us on stand 905 at the Embedded Systems Show 2008 <<<<
   >>>> Oct 1-2, NEC, Birmingham, UK http://www.embedded.co.uk  <<<<


_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users







_______________________________________________
lwip-users mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/lwip-users



--
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["The best things in life aren't things."]------      Opinions==mine




reply via email to

[Prev in Thread] Current Thread [Next in Thread]