lwip-users
[Top][All Lists]
Advanced

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

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


From: Jonathan Larmour
Subject: Re: [lwip-users] Non-blocking socket I/O
Date: Fri, 07 Mar 2008 17:10:04 +0000
User-agent: Thunderbird 1.5.0.12 (X11/20070530)

Muhamad Ikhwan Ismail wrote:
> I am now trying
> to implement non-blocking socket operation for
> connect() and write(). For accept() and read() the socket is now
> non-blocking since I use select().
>  I am aware that there is such a thread previously, however it ends with
> no clear result.
> 
> I am wondering why do we have to block write() from the first place?

Because a TCP/IP stack only has so much memory... particularly true for
lwIP! Every TCP/IP stack has a restriction on the size of send buffers. And
when they fill, the application blocks.

> And as for connect(), I am planing to implement the following changes:
> 
> 1. in netconn_connect(), if the O_NONBLOCK flag is set, then use
> sys_arch_mbox_try_fetch() and return EINPROGRESS. Then set the netconn state
> to NETCONN_CONNECT. Any subsequent connect checks the NETCONN_CONNECT
> state and returns EALREADY
> 
> 2. Use the callback function to set the sendevent to plus in the
> do_connected().
> 
> 3. Select() after connection is established will then return a non-zero
> nready for the writeset.
>  The application then call sys_arch_mbox_tryfetch, free the message,
> reset the send event to zero and can now begin writing/reading to the
> socket.
> 
> Is there any changes or conflicts I should be aware of if i do implement
> these changes ?

Without some wider changes 1) would break layering, so that would probably
have to be something you change just for yourself.

2) may require extra changes since you will have to initialise the socket's
sendevent field to 0. This wouldn't work straightaway for UDP or RAW sockets.

Jifl
-- 
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
 **  Visit us at ESC Silicon Valley <http://www.embedded.com/esc/sv>  **
 **  April 15-17 2008, Booth 3012, San Jose McEnery Convention Center **
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




reply via email to

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