[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lwip-users] lwip_accept acceptmbox is NULL
From: |
Jonathan Larmour |
Subject: |
Re: [lwip-users] lwip_accept acceptmbox is NULL |
Date: |
Tue, 07 Oct 2008 18:34:46 +0100 |
User-agent: |
Thunderbird 1.5.0.12 (X11/20070530) |
Emmanuel Baguia Jr. wrote:
> Here are some code snippets using the APIs:
>
> struct netconn *conn, *newconn;
> conn = netconn_new(NETCONN_TCP);
> printf("http_test: socket created !\n");
> netconn_bind(conn, NULL, 8084);
I don't think you should be using NULL here. You should pass in IP_ADDR_ANY
instead.
> printf("http_test: socket binded !\n");
> netconn_listen(conn);
> printf("http_test: socket listen !\n");
> // Where I placed the acceptmbox initialization
> while( 1 )
> {
> newconn = netconn_accept(conn);
> printf("http_test: socket accept !\n");
> }
> netconn_close(conn);
> Until I noticed that I needed to initialize the acceptmbox if it is null
> after calling netconn_listen and before calling the netconn_accept.
> if( conn->acceptmbox == NULL )
> {
> conn->acceptmbox = sys_mbox_new(DEFAULT_ACCEPTMBOX_SIZE);
> }
>
> Then everything worked! :) Is there a way to do this in the
> lwip/socket.h? Or maybe I just missed something?
It would be good to check the return values of the netconn* functions.
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