[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [lwip-users] lwip_accept() blocks for non-blocking sockets ? - Email
From: |
Tamas Somogyi |
Subject: |
RE: [lwip-users] lwip_accept() blocks for non-blocking sockets ? - Email found in subject |
Date: |
Wed, 1 Oct 2008 09:30:57 +0100 |
It seems that the below-mentioned fix solves the problem in my
application indeed. Thanks guys for the quick solution!
Tamas
-----Original Message-----
From: address@hidden
[mailto:address@hidden On
Behalf Of address@hidden
Sent: 30 September 2008 18:25
To: Mailing list for lwIP users
Subject: Re: [lwip-users] lwip_accept() blocks for non-blocking sockets
? - Email found in subject
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))
{
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- RE: [lwip-users] lwip_accept() blocks for non-blocking sockets ? - Email found in subject,
Tamas Somogyi <=