Problems getting a basic example running

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Problems getting a basic example running

Fre Net
Hi,
I just started looking at the lwip stack and was trying to build a simple console app that would create a udp socket and fire off some data.

I am using Ubuntu 10.04 on a desktop PC and want to use the sockets api (lwip 1.4.0 & contrib files 1.4.0). I felt that this would be the simplest way to start off. Eventually I would like to move over to our ARM board running Ubuntu.

I am getting errors when initially trying to create the udp socket. This is the code:

int sockfd;
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
 perror("socket?");
 exit(1);
}


This is the error message: 

lwip_socket(PF_INET, SOCK_DGRAM, 0) = -1 / ENOBUFS (could not create netconn)


I have also tried incorporating the socket_examples functions in the contrib package in a simple app and get the same error. I've enabled udp and tcip in my options file. Is there another option that I have overlooked? Does anyone have an example of a basic app that creates a udp socket and sends some data? If there is any other info that I can provide, let me know. 

Thanks,
Fred


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Problems getting a basic example running

Kieran Mansley
On Tue, 2012-07-24 at 18:35 -0700, Fre Net wrote:
>
> This is the error message:
>
> lwip_socket(PF_INET, SOCK_DGRAM, 0) = -1 / ENOBUFS (could not create
> netconn)

My guess is that something in your lwipopts.h file is not set high
enough to allow the socket to be created.  If you can post your file
here someone might be able to suggest a solution.

Kieran


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Problems getting a basic example running

Fre Net
I've attached the lwipopts.h file that I am using. Please let me know if there is anything that I may have configured incorrectly that would prevent the socket from being created.

Thanks,
Fred

On Mon, Aug 6, 2012 at 8:05 AM, Kieran Mansley <[hidden email]> wrote:
On Tue, 2012-07-24 at 18:35 -0700, Fre Net wrote:
>
> This is the error message:
>
> lwip_socket(PF_INET, SOCK_DGRAM, 0) = -1 / ENOBUFS (could not create
> netconn)

My guess is that something in your lwipopts.h file is not set high
enough to allow the socket to be created.  If you can post your file
here someone might be able to suggest a solution.

Kieran


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users

lwipopts.h (15K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Problems getting a basic example running

Fre Net
I've got some more info in the hopes that this will help...

I've debugged a bit more and found that from within tcpip_apimsg():

sys_mbox_valid(&mbox) is failing causing a return of ERR_VAL.

This in turn causes netconn_new_with_proto_and_callback() to return NULL. I am not sure why it is failing. netconn_new_with_proto_and_callback() is not failing at the asserts after the tcpip_apimsg() call.

Thanks,
Fred


On Mon, Aug 13, 2012 at 4:25 PM, Fre Net <[hidden email]> wrote:
I've attached the lwipopts.h file that I am using. Please let me know if there is anything that I may have configured incorrectly that would prevent the socket from being created.

Thanks,
Fred


On Mon, Aug 6, 2012 at 8:05 AM, Kieran Mansley <[hidden email]> wrote:
On Tue, 2012-07-24 at 18:35 -0700, Fre Net wrote:
>
> This is the error message:
>
> lwip_socket(PF_INET, SOCK_DGRAM, 0) = -1 / ENOBUFS (could not create
> netconn)

My guess is that something in your lwipopts.h file is not set high
enough to allow the socket to be created.  If you can post your file
here someone might be able to suggest a solution.

Kieran


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users



_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Problems getting a basic example running

Kieran Mansley

On 22 Aug 2012, at 02:18, Fre Net wrote:

> I've got some more info in the hopes that this will help...
>
> I've debugged a bit more and found that from within tcpip_apimsg():
>
> sys_mbox_valid(&mbox) is failing causing a return of ERR_VAL.
>
> This in turn causes netconn_new_with_proto_and_callback() to return NULL. I am not sure why it is failing. netconn_new_with_proto_and_callback() is not failing at the asserts after the tcpip_apimsg() call.
>

That suggests that it hasn't been initialised.  How are you initialising lwIP in your project?

Kieran
_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Problems getting a basic example running

Fre Net
I'm using lwip_init() to initialize LWIP. Is this not the correct way to do this? Here's the code from the start of my program to where the error occurs:

int sockfd;
struct sockaddr_in their_addr; // connector's address information
struct hostent *he;
int numbytes;
int broadcast = 1;
lwip_init();

if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
 perror("socket?");
 exit(1);
}


Thanks,
Fred

On Fri, Aug 24, 2012 at 11:34 AM, Kieran Mansley <[hidden email]> wrote:

On 22 Aug 2012, at 02:18, Fre Net wrote:

> I've got some more info in the hopes that this will help...
>
> I've debugged a bit more and found that from within tcpip_apimsg():
>
> sys_mbox_valid(&mbox) is failing causing a return of ERR_VAL.
>
> This in turn causes netconn_new_with_proto_and_callback() to return NULL. I am not sure why it is failing. netconn_new_with_proto_and_callback() is not failing at the asserts after the tcpip_apimsg() call.
>

That suggests that it hasn't been initialised.  How are you initialising lwIP in your project?

Kieran
_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Problems getting a basic example running

Martin Velek
Hello,

this is not the correct way. You should not call lwip_init by
yourselves when NO_SYS = 0. You have to call tcpip_init() which will
call lwip_init(). To setup interface you should call netifapi_netif_*
functions.
Check this site http://lwip.wikia.com/wiki/Initialization_using_tcpip.c

Martin


On Tue, Aug 28, 2012 at 12:14 AM, Fre Net <[hidden email]> wrote:

> I'm using lwip_init() to initialize LWIP. Is this not the correct way to do
> this? Here's the code from the start of my program to where the error
> occurs:
>
> int sockfd;
> struct sockaddr_in their_addr; // connector's address information
> struct hostent *he;
> int numbytes;
> int broadcast = 1;
> lwip_init();
>
> if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
>  perror("socket?");
>  exit(1);
> }
>
>
> Thanks,
> Fred
>
> On Fri, Aug 24, 2012 at 11:34 AM, Kieran Mansley <[hidden email]> wrote:
>>
>>
>> On 22 Aug 2012, at 02:18, Fre Net wrote:
>>
>> > I've got some more info in the hopes that this will help...
>> >
>> > I've debugged a bit more and found that from within tcpip_apimsg():
>> >
>> > sys_mbox_valid(&mbox) is failing causing a return of ERR_VAL.
>> >
>> > This in turn causes netconn_new_with_proto_and_callback() to return
>> > NULL. I am not sure why it is failing. netconn_new_with_proto_and_callback()
>> > is not failing at the asserts after the tcpip_apimsg() call.
>> >
>>
>> That suggests that it hasn't been initialised.  How are you initialising
>> lwIP in your project?
>>
>> Kieran
>> _______________________________________________
>> lwip-users mailing list
>> [hidden email]
>> https://lists.nongnu.org/mailman/listinfo/lwip-users
>
>
>
> _______________________________________________
> lwip-users mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/lwip-users

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users