lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] Non-blocking I/O in lwip


From: Simon Goldschmidt
Subject: Re: [lwip-users] Non-blocking I/O in lwip
Date: Fri, 22 Jul 2011 18:54:58 +0200

Francesco Sacchi <address@hidden> wrote:

> Il 22/07/2011 12:36, Simon Goldschmidt ha scritto:
>> 
>> Francesco Sacchi<address@hidden>  wrote:
>>> We see that non-blocking sending has been implemented in lwip-1.4, and
>>> here is our question: if we upgrade will this issue be solved?
>>> 
>>> In other words, if I open a socket in non-blocking mode, I suppose that
>>> the lwip_send() will return an error in case it would block
>>> (EWOULDBLOCK), but then, if I close the socket, will the memory
>>> allocated be freed correctly?
>> 
>> Yes, 1.4.0 should work for you: if no buffers are available, a non-blocking 
>> send returns EWOULDBLOCK (which a blocking send waits indefinitly for memory 
>> to become available).
> 
> Ok, but if I close a blocked socket, will the memory allocated by the socket 
> itself be freed?

No, you can't close a blocked socket: lwIP's socket implementation does not 
allow a socket to be used from more than one thread at once, so calling close() 
from one thread while another thread is blocked in send() wont work.

> 
>> However, you might want to control the amount of data buffered on the 
>> listening connection so that the out-of-memory condition doesn't happen at 
>> all?
> 
> Could you be more specific? What listenig connection do you refer to? If you 
> are talking about the server side connection, that is not accessible to us 
> because resides on a PC and the software is not editable by us.

Ok, in that case I misunderstood you. I thought the server that blocks would 
run on the same lwIP device. Being like that, non-blocking send is the way to 
go.

Simon


reply via email to

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