YAP | 1 Jan 2009 23:00
Picon

Listen on more then one port with lwIP

I am new to lwIP and use it with FreeRTOS on a PIC32 so be patient
with  me if this is just a  silly question.

I want to have a web server plus a custom interface on the firmware I
work on at the moment. So I try to solve this starting a new thread
where I initialised lwip and then start two listner threads for the
two ports.

This does not work however even if they each work perfect on there own.

How should this be coded correctly?  Any hints appreciated.

My listner thread look like this

///////////////////////////////////////////////////////////////////////////////
// taskVSCPListner
//

void taskVSCPListner( void *pvParameters )
{
    struct netconn *pxVSCPListener;     // Listens for VSCP connections
    struct netconn *pxNewConnection;

    // Create a new tcp connection handle for VSCP
 	pxVSCPListener = netconn_new( NETCONN_TCP );
	netconn_bind( pxVSCPListener, NULL, VSCP_LEVEL2_TCP_PORT );
	netconn_listen( pxVSCPListener );

	// Loop forever
	for( ;; ) {
(Continue reading)

Muhamad Ikhwan Ismail | 2 Jan 2009 10:31
Picon
Favicon

RE: Listen on more then one port with lwIP


Hi,

It would help the developer answer your question, if you explain what do you mean by it does not work
e.g. where it blocks, you are getting no data or something like that. You should also search the mailing list
for previous posts, someone might have asked the same q.

You might want to info them also of your port and version.

Greetings
Ikhwan


> Date: Thu, 1 Jan 2009 23:00:54 +0100
> From: x112358-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> To: lwip-users-qX2TKyscuCcdnm+yROfE0A@public.gmane.org
> Subject: [lwip-users] Listen on more then one port with lwIP
>
> I am new to lwIP and use it with FreeRTOS on a PIC32 so be patient
> with me if this is just a silly question.
>
> I want to have a web server plus a custom interface on the firmware I
> work on at the moment. So I try to solve this starting a new thread
> where I initialised lwip and then start two listner threads for the
> two ports.
>
> This does not work however even if they each work perfect on there own.
>
> How should this be coded correctly? Any hints appreciated.
>
> My listner thread look like this
>
> ///////////////////////////////////////////////////////////////////////////////
> // taskVSCPListner
> //
>
> void taskVSCPListner( void *pvParameters )
> {
> struct netconn *pxVSCPListener; // Listens for VSCP connections
> struct netconn *pxNewConnection;
>
> // Create a new tcp connection handle for VSCP
> pxVSCPListener = netconn_new( NETCONN_TCP );
> netconn_bind( pxVSCPListener, NULL, VSCP_LEVEL2_TCP_PORT );
> netconn_listen( pxVSCPListener );
>
> // Loop forever
> for( ;; ) {
>
> // Wait for connection.
> pxNewConnection = netconn_accept( pxVSCPListener );
>
> if ( pxNewConnection != NULL ) {
>
> // Service connection.
> vProcessVSCPConnection( pxNewConnection );
>
> while( netconn_delete( pxNewConnection ) != ERR_OK ) {
> vTaskDelay( webSHORT_DELAY );
> }
>
> }
>
> }
> }
>
>
> ///////////////////////////////////////////////////////////////////////////////
> // taskHTTPListner
> //
>
> void taskHTTPListner( void *pvParameters )
> {
> struct netconn *pxHTTPListener; // Listens for HTTP connections
> struct netconn *pxNewConnection;
>
> // Create a new tcp connection handle for HTTP
> pxHTTPListener = netconn_new( NETCONN_TCP );
> netconn_bind( pxHTTPListener, NULL, webHTTP_PORT );
> netconn_listen( pxHTTPListener );
>
> // Create a new tcp connection handle for VSCP
> //pxVSCPListener = netconn_new( NETCONN_TCP );
> //netconn_bind( pxHTTPListener, NULL, VSCP_LEVEL2_TCP_PORT );
> //netconn_listen( pxVSCPListener );
>
> // Loop forever
> for( ;; ) {
>
> // Wait for connection.
> pxNewConnection = netconn_accept( pxHTTPListener );
>
> if ( pxNewConnection != NULL ) {
>
> // Service connection.
> vProcessConnection( pxNewConnection );
>
> while( netconn_delete( pxNewConnection ) != ERR_OK ) {
> vTaskDelay( webSHORT_DELAY );
> }
>
> }
>
> }
> }
>
> Cheers
> /Ake
>
>
> --
> ---
> Ake Hedman
> D of Scandinavia, http://www.dofscandinavia.com
>
>
> _______________________________________________
> lwip-users mailing list
> lwip-users-qX2TKyscuCcdnm+yROfE0A@public.gmane.org
> http://lists.nongnu.org/mailman/listinfo/lwip-users

It’s the same Hotmail®. If by “same” you mean up to 70% faster. Get your account now.
_______________________________________________
lwip-users mailing list
lwip-users@...
http://lists.nongnu.org/mailman/listinfo/lwip-users
YAP | 2 Jan 2009 10:55
Picon

Re: Listen on more then one port with lwIP

as you top post I do so to so the source is preserved below.

lwIP version is 1.3
Microchip GCC C32 MIPS compiler
FreeRTOS 5.1.0

By not working I mean  none of the listner threads return after
netconn_accept which they do if I only have one thread.

I pretty much expected this to be a usage fault and that the way I use
dthe code was invalid.

Cheers
/Ake

On Fri, Jan 2, 2009 at 10:31 AM, Muhamad Ikhwan Ismail
<dysfunction_81@...> wrote:
>
> Hi,
>
> It would help the developer answer your question, if you explain what do you
> mean by it does not work
> e.g. where it blocks, you are getting no data or something like that. You
> should also search the mailing list
> for previous posts, someone might have asked the same q.
>
> You might want to info them also of your port and version.
>
> Greetings
> Ikhwan
>
>
>> Date: Thu, 1 Jan 2009 23:00:54 +0100
>> From: x112358@...
>> To: lwip-users@...
>> Subject: [lwip-users] Listen on more then one port with lwIP
>>
>> I am new to lwIP and use it with FreeRTOS on a PIC32 so be patient
>> with me if this is just a silly question.
>>
>> I want to have a web server plus a custom interface on the firmware I
>> work on at the moment. So I try to solve this starting a new thread
>> where I initialised lwip and then start two listner threads for the
>> two ports.
>>
>> This does not work however even if they each work perfect on there own.
>>
>> How should this be coded correctly? Any hints appreciated.
>>
>> My listner thread look like this
>>
>>
>> ///////////////////////////////////////////////////////////////////////////////
>> // taskVSCPListner
>> //
>>
>> void taskVSCPListner( void *pvParameters )
>> {
>> struct netconn *pxVSCPListener; // Listens for VSCP connections
>> struct netconn *pxNewConnection;
>>
>> // Create a new tcp connection handle for VSCP
>> pxVSCPListener = netconn_new( NETCONN_TCP );
>> netconn_bind( pxVSCPListener, NULL, VSCP_LEVEL2_TCP_PORT );
>> netconn_listen( pxVSCPListener );
>>
>> // Loop forever
>> for( ;; ) {
>>
>> // Wait for connection.
>> pxNewConnection = netconn_accept( pxVSCPListener );
>>
>> if ( pxNewConnection != NULL ) {
>>
>> // Service connection.
>> vProcessVSCPConnection( pxNewConnection );
>>
>> while( netconn_delete( pxNewConnection ) != ERR_OK ) {
>> vTaskDelay( webSHORT_DELAY );
>> }
>>
>> }
>>
>> }
>> }
>>
>>
>>
>> ///////////////////////////////////////////////////////////////////////////////
>> // taskHTTPListner
>> //
>>
>> void taskHTTPListner( void *pvParameters )
>> {
>> struct netconn *pxHTTPListener; // Listens for HTTP connections
>> struct netconn *pxNewConnection;
>>
>> // Create a new tcp connection handle for HTTP
>> pxHTTPListener = netconn_new( NETCONN_TCP );
>> netconn_bind( pxHTTPListener, NULL, webHTTP_PORT );
>> netconn_listen( pxHTTPListener );
>>
>> // Create a new tcp connection handle for VSCP
>> //pxVSCPListener = netconn_new( NETCONN_TCP );
>> //netconn_bind( pxHTTPListener, NULL, VSCP_LEVEL2_TCP_PORT );
>> //netconn_listen( pxVSCPListener );
>>
>> // Loop forever
>> for( ;; ) {
>>
>> // Wait for connection.
>> pxNewConnection = netconn_accept( pxHTTPListener );
>>
>> if ( pxNewConnection != NULL ) {
>>
>> // Service connection.
>> vProcessConnection( pxNewConnection );
>>
>> while( netconn_delete( pxNewConnection ) != ERR_OK ) {
>> vTaskDelay( webSHORT_DELAY );
>> }
>>
>> }
>>
>> }
>> }
>>
>> Cheers
>> /Ake
>>
>>
>> --
>> ---
>> Ake Hedman
>> D of Scandinavia, http://www.dofscandinavia.com
>>
>>
>> _______________________________________________
>> lwip-users mailing list
>> lwip-users@...
>> http://lists.nongnu.org/mailman/listinfo/lwip-users
>
> ________________________________
> It's the same Hotmail(R). If by "same" you mean up to 70% faster. Get your
> account now.
> _______________________________________________
> lwip-users mailing list
> lwip-users@...
> http://lists.nongnu.org/mailman/listinfo/lwip-users
>

--

-- 
 ---
Ake Hedman
D of Scandinavia, http://www.dofscandinavia.com
Muhamad Ikhwan Ismail | 2 Jan 2009 11:06
Picon
Favicon

RE: Listen on more then one port with lwIP


Hi,

It seems to me you might have a concurrent access problem on your sys_arch layer since
when you had the 2 listener socket in a single task, it worked. Try something like this,

-Block both thread
-start one of them, and wait till the netconn_accept is done
-start the 2nd thread after that

If it works then my assumption could be right. The only thing the 2 socket shares in netconn_accept is the
mailbox of the tcpip tasks and the same function call on sys_arch layers.

If that the case you might wanna do preemption protection to critical codes in the sys_arch layer?

> Date: Fri, 2 Jan 2009 10:55:06 +0100
> From: x112358-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> To: lwip-users-qX2TKyscuCdQFI55V6+gNQ@public.gmane.orgg
> Subject: Re: [lwip-users] Listen on more then one port with lwIP
>
> as you top post I do so to so the source is preserved below.
>
> lwIP version is 1.3
> Microchip GCC C32 MIPS compiler
> FreeRTOS 5.1.0
>
> By not working I mean none of the listner threads return after
> netconn_accept which they do if I only have one thread.
>
> I pretty much expected this to be a usage fault and that the way I use
> dthe code was invalid.
>
> Cheers
> /Ake
>
> On Fri, Jan 2, 2009 at 10:31 AM, Muhamad Ikhwan Ismail
> <dysfunction_81-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:
> >
> > Hi,
> >
> > It would help the developer answer your question, if you explain what do you
> > mean by it does not work
> > e.g. where it blocks, you are getting no data or something like that. You
> > should also search the mailing list
> > for previous posts, someone might have asked the same q.
> >
> > You might want to info them also of your port and version.
> >
> > Greetings
> > Ikhwan
> >
> >
> >> Date: Thu, 1 Jan 2009 23:00:54 +0100
> >> From: x112358-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
> >> To: lwip-users-qX2TKyscuCcdnm+yROfE0A@public.gmane.org
> >> Subject: [lwip-users] Listen on more then one port with lwIP
> >>
> >> I am new to lwIP and use it with FreeRTOS on a PIC32 so be patient
> >> with me if this is just a silly question.
> >>
> >> I want to have a web server plus a custom interface on the firmware I
> >> work on at the moment. So I try to solve this starting a new thread
> >> where I initialised lwip and then start two listner threads for the
> >> two ports.
> >>
> >> This does not work however even if they each work perfect on there own.
> >>
> >> How should this be coded correctly? Any hints appreciated.
> >>
> >> My listner thread look like this
> >>
> >>
> >> ///////////////////////////////////////////////////////////////////////////////
> >> // taskVSCPListner
> >> //
> >>
> >> void taskVSCPListner( void *pvParameters )
> >> {
> >> struct netconn *pxVSCPListener; // Listens for VSCP connections
> >> struct netconn *pxNewConnection;
> >>
> >> // Create a new tcp connection handle for VSCP
> >> pxVSCPListener = netconn_new( NETCONN_TCP );
> >> netconn_bind( pxVSCPListener, NULL, VSCP_LEVEL2_TCP_PORT );
> >> netconn_listen( pxVSCPListener );
> >>
> >> // Loop forever
> >> for( ;; ) {
> >>
> >> // Wait for connection.
> >> pxNewConnection = netconn_accept( pxVSCPListener );
> >>
> >> if ( pxNewConnection != NULL ) {
> >>
> >> // Service connection.
> >> vProcessVSCPConnection( pxNewConnection );
> >>
> >> while( netconn_delete( pxNewConnection ) != ERR_OK ) {
> >> vTaskDelay( webSHORT_DELAY );
> >> }
> >>
> >> }
> >>
> >> }
> >> }
> >>
> >>
> >>
> >> ///////////////////////////////////////////////////////////////////////////////
> >> // taskHTTPListner
> >> //
> >>
> >> void taskHTTPListner( void *pvParameters )
> >> {
> >> struct netconn *pxHTTPListener; // Listens for HTTP connections
> >> struct netconn *pxNewConnection;
> >>
> >> // Create a new tcp connection handle for HTTP
> >> pxHTTPListener = netconn_new( NETCONN_TCP );
> >> netconn_bind( pxHTTPListener, NULL, webHTTP_PORT );
> >> netconn_listen( pxHTTPListener );
> >>
> >> // Create a new tcp connection handle for VSCP
> >> //pxVSCPListener = netconn_new( NETCONN_TCP );
> >> //netconn_bind( pxHTTPListener, NULL, VSCP_LEVEL2_TCP_PORT );
> >> //netconn_listen( pxVSCPListener );
> >>
> >> // Loop forever
> >> for( ;; ) {
> >>
> >> // Wait for connection.
> >> pxNewConnection = netconn_accept( pxHTTPListener );
> >>
> >> if ( pxNewConnection != NULL ) {
> >>
> >> // Service connection.
> >> vProcessConnection( pxNewConnection );
> >>
> >> while( netconn_delete( pxNewConnection ) != ERR_OK ) {
> >> vTaskDelay( webSHORT_DELAY );
> >> }
> >>
> >> }
> >>
> >> }
> >> }
> >>
> >> Cheers
> >> /Ake
> >>
> >>
> >> --
> >> ---
> >> Ake Hedman
> >> D of Scandinavia, http://www.dofscandinavia.com
> >>
> >>
> >> _______________________________________________
> >> lwip-users mailing list
> >> lwip-users-qX2TKyscuCcdnm+yROfE0A@public.gmane.org
> >> http://lists.nongnu.org/mailman/listinfo/lwip-users
> >
> > ________________________________
> > It's the same Hotmail(R). If by "same" you mean up to 70% faster. Get your
> > account now.
> > _______________________________________________
> > lwip-users mailing list
> > lwip-users-qX2TKyscuCcdnm+yROfE0A@public.gmane.org
> > http://lists.nongnu.org/mailman/listinfo/lwip-users
> >
>
>
>
> --
> ---
> Ake Hedman
> D of Scandinavia, http://www.dofscandinavia.com
>
>
> _______________________________________________
> lwip-users mailing list
> lwip-users-qX2TKyscuCcdnm+yROfE0A@public.gmane.org
> http://lists.nongnu.org/mailman/listinfo/lwip-users

Send e-mail anywhere. No map, no compass. Get your Hotmail® account now.
_______________________________________________
lwip-users mailing list
lwip-users@...
http://lists.nongnu.org/mailman/listinfo/lwip-users
YAP | 2 Jan 2009 16:30
Picon

Re: Listen on more then one port with lwIP

OK Thanks I will try that.

I noticed that netcon_new returns zero if both threads are started so
the problem really appears to be there. Looks like a memory problem.

/Ake

On Fri, Jan 2, 2009 at 11:06 AM, Muhamad Ikhwan Ismail
<dysfunction_81@...> wrote:
>
> Hi,
>
> It seems to me you might have a concurrent access problem on your sys_arch
> layer since
> when you had the 2 listener socket in a single task, it worked. Try
> something like this,
>
> -Block both thread
> -start one of them, and wait till the netconn_accept is done
> -start the 2nd thread after that
>
> If it works then my assumption could be right. The only thing the 2 socket
> shares in netconn_accept is the
> mailbox of the tcpip tasks and the same function call on sys_arch layers.
>
> If that the case you might wanna do preemption protection to critical codes
> in the sys_arch layer?
>
>> Date: Fri, 2 Jan 2009 10:55:06 +0100
>> From: x112358@...
>> To: lwip-users@...
>> Subject: Re: [lwip-users] Listen on more then one port with lwIP
>>
>> as you top post I do so to so the source is preserved below.
>>
>> lwIP version is 1.3
>> Microchip GCC C32 MIPS compiler
>> FreeRTOS 5.1.0
>>
>> By not working I mean none of the listner threads return after
>> netconn_accept which they do if I only have one thread.
>>
>> I pretty much expected this to be a usage fault and that the way I use
>> dthe code was invalid.
>>
>> Cheers
>> /Ake
>>
>> On Fri, Jan 2, 2009 at 10:31 AM, Muhamad Ikhwan Ismail
>> <dysfunction_81@...> wrote:
>> >
>> > Hi,
>> >
>> > It would help the developer answer your question, if you explain what do
>> > you
>> > mean by it does not work
>> > e.g. where it blocks, you are getting no data or something like that.
>> > You
>> > should also search the mailing list
>> > for previous posts, someone might have asked the same q.
>> >
>> > You might want to info them also of your port and version.
>> >
>> > Greetings
>> > Ikhwan
>> >
>> >
>> >> Date: Thu, 1 Jan 2009 23:00:54 +0100
>> >> From: x112358@...
>> >> To: lwip-users@...
>> >> Subject: [lwip-users] Listen on more then one port with lwIP
>> >>
>> >> I am new to lwIP and use it with FreeRTOS on a PIC32 so be patient
>> >> with me if this is just a silly question.
>> >>
>> >> I want to have a web server plus a custom interface on the firmware I
>> >> work on at the moment. So I try to solve this starting a new thread
>> >> where I initialised lwip and then start two listner threads for the
>> >> two ports.
>> >>
>> >> This does not work however even if they each work perfect on there own.
>> >>
>> >> How should this be coded correctly? Any hints appreciated.
>> >>
>> >> My listner thread look like this
>> >>
>> >>
>> >>
>> >> ///////////////////////////////////////////////////////////////////////////////
>> >> // taskVSCPListner
>> >> //
>> >>
>> >> void taskVSCPListner( void *pvParameters )
>> >> {
>> >> struct netconn *pxVSCPListener; // Listens for VSCP connections
>> >> struct netconn *pxNewConnection;
>> >>
>> >> // Create a new tcp connection handle for VSCP
>> >> pxVSCPListener = netconn_new( NETCONN_TCP );
>> >> netconn_bind( pxVSCPListener, NULL, VSCP_LEVEL2_TCP_PORT );
>> >> netconn_listen( pxVSCPListener );
>> >>
>> >> // Loop forever
>> >> for( ;; ) {
>> >>
>> >> // Wait for connection.
>> >> pxNewConnection = netconn_accept( pxVSCPListener );
>> >>
>> >> if ( pxNewConnection != NULL ) {
>> >>
>> >> // Service connection.
>> >> vProcessVSCPConnection( pxNewConnection );
>> >>
>> >> while( netconn_delete( pxNewConnection ) != ERR_OK ) {
>> >> vTaskDelay( webSHORT_DELAY );
>> >> }
>> >>
>> >> }
>> >>
>> >> }
>> >> }
>> >>
>> >>
>> >>
>> >>
>> >> ///////////////////////////////////////////////////////////////////////////////
>> >> // taskHTTPListner
>> >> //
>> >>
>> >> void taskHTTPListner( void *pvParameters )
>> >> {
>> >> struct netconn *pxHTTPListener; // Listens for HTTP connections
>> >> struct netconn *pxNewConnection;
>> >>
>> >> // Create a new tcp connection handle for HTTP
>> >> pxHTTPListener = netconn_new( NETCONN_TCP );
>> >> netconn_bind( pxHTTPListener, NULL, webHTTP_PORT );
>> >> netconn_listen( pxHTTPListener );
>> >>
>> >> // Create a new tcp connection handle for VSCP
>> >> //pxVSCPListener = netconn_new( NETCONN_TCP );
>> >> //netconn_bind( pxHTTPListener, NULL, VSCP_LEVEL2_TCP_PORT );
>> >> //netconn_listen( pxVSCPListener );
>> >>
>> >> // Loop forever
>> >> for( ;; ) {
>> >>
>> >> // Wait for connection.
>> >> pxNewConnection = netconn_accept( pxHTTPListener );
>> >>
>> >> if ( pxNewConnection != NULL ) {
>> >>
>> >> // Service connection.
>> >> vProcessConnection( pxNewConnection );
>> >>
>> >> while( netconn_delete( pxNewConnection ) != ERR_OK ) {
>> >> vTaskDelay( webSHORT_DELAY );
>> >> }
>> >>
>> >> }
>> >>
>> >> }
>> >> }
>> >>
>> >> Cheers
>> >> /Ake
>> >>
>> >>
>> >> --
>> >> ---
>> >> Ake Hedman
>> >> D of Scandinavia, http://www.dofscandinavia.com
>> >>
>> >>
>> >> _______________________________________________
>> >> lwip-users mailing list
>> >> lwip-users@...
>> >> http://lists.nongnu.org/mailman/listinfo/lwip-users
>> >
>> > ________________________________
>> > It's the same Hotmail(R). If by "same" you mean up to 70% faster. Get
>> > your
>> > account now.
>> > _______________________________________________
>> > lwip-users mailing list
>> > lwip-users@...
>> > http://lists.nongnu.org/mailman/listinfo/lwip-users
>> >
>>
>>
>>
>> --
>> ---
>> Ake Hedman
>> D of Scandinavia, http://www.dofscandinavia.com
>>
>>
>> _______________________________________________
>> lwip-users mailing list
>> lwip-users@...
>> http://lists.nongnu.org/mailman/listinfo/lwip-users
>
> ________________________________
> Send e-mail anywhere. No map, no compass. Get your Hotmail(R) account now.
> _______________________________________________
> lwip-users mailing list
> lwip-users@...
> http://lists.nongnu.org/mailman/listinfo/lwip-users
>

--

-- 
 ---
Ake Hedman
D of Scandinavia, http://www.dofscandinavia.com
Jonathan Larmour | 3 Jan 2009 16:32
Favicon

Re: Implementing Ftp File Transfert : Non blocking Send ?

Paul THILLOY wrote:
> 
> if the transfert is interrupted by some disconnection...then it is 
> impossible to leave the send or write function...Am I doing something 
> wrong ?

I remember people before saying the timeouts are just very very long, 
something like a few hours IIRC. However looking at the code, I can't find 
any code that will terminate a connection unless you use the SO_KEEPALIVE 
socket option. For my own interest, I'd be grateful if someone could tell 
me where this is done when keepalives are off.

Nevertheless you can use that option with setsockopt(). You can also 
change the keepalive timeouts by enabling LWIP_TCP_KEEPALIVE in 
lwipopts.h, and then using either TCP_KEEPALIVE or TCP_KEEPIDLE, possibly 
also with TCP_KEEPINTVL and TCP_KEEPCNT options. Look at 
include/lwip/sockets.h, and note that include/lwip/tcp.h has the defaults 
and note what it says about RFC 1122.

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.
------["The best things in life aren't things."]------      Opinions==mine
YAP | 3 Jan 2009 18:26
Picon

Re: Listen on more then one port with lwIP

On Fri, Jan 2, 2009 at 4:30 PM, YAP <x112358@...> wrote:
> OK Thanks I will try that.
>
> I noticed that netcon_new returns zero if both threads are started so
> the problem really appears to be there. Looks like a memory problem.
>
> /Ake

OK I found the problem. MEMP_NUM_NETBUF  and MEMP_NUM_NETCONN was set
to low (2) and increasing the values (4) made things work. I was not
aware that the listen also counted as a connection but is quite
understandable now when I discovered the problem.

Cheers
/Ake

>
>
> On Fri, Jan 2, 2009 at 11:06 AM, Muhamad Ikhwan Ismail
> <dysfunction_81@...> wrote:
>>
>> Hi,
>>
>> It seems to me you might have a concurrent access problem on your sys_arch
>> layer since
>> when you had the 2 listener socket in a single task, it worked. Try
>> something like this,
>>
>> -Block both thread
>> -start one of them, and wait till the netconn_accept is done
>> -start the 2nd thread after that
>>
>> If it works then my assumption could be right. The only thing the 2 socket
>> shares in netconn_accept is the
>> mailbox of the tcpip tasks and the same function call on sys_arch layers.
>>
>> If that the case you might wanna do preemption protection to critical codes
>> in the sys_arch layer?
>>
>>> Date: Fri, 2 Jan 2009 10:55:06 +0100
>>> From: x112358@...
>>> To: lwip-users@...
>>> Subject: Re: [lwip-users] Listen on more then one port with lwIP
>>>
>>> as you top post I do so to so the source is preserved below.
>>>
>>> lwIP version is 1.3
>>> Microchip GCC C32 MIPS compiler
>>> FreeRTOS 5.1.0
>>>
>>> By not working I mean none of the listner threads return after
>>> netconn_accept which they do if I only have one thread.
>>>
>>> I pretty much expected this to be a usage fault and that the way I use
>>> dthe code was invalid.
>>>
>>> Cheers
>>> /Ake
>>>
>>> On Fri, Jan 2, 2009 at 10:31 AM, Muhamad Ikhwan Ismail
>>> <dysfunction_81@...> wrote:
>>> >
>>> > Hi,
>>> >
>>> > It would help the developer answer your question, if you explain what do
>>> > you
>>> > mean by it does not work
>>> > e.g. where it blocks, you are getting no data or something like that.
>>> > You
>>> > should also search the mailing list
>>> > for previous posts, someone might have asked the same q.
>>> >
>>> > You might want to info them also of your port and version.
>>> >
>>> > Greetings
>>> > Ikhwan
>>> >
>>> >
>>> >> Date: Thu, 1 Jan 2009 23:00:54 +0100
>>> >> From: x112358@...
>>> >> To: lwip-users@...
>>> >> Subject: [lwip-users] Listen on more then one port with lwIP
>>> >>
>>> >> I am new to lwIP and use it with FreeRTOS on a PIC32 so be patient
>>> >> with me if this is just a silly question.
>>> >>
>>> >> I want to have a web server plus a custom interface on the firmware I
>>> >> work on at the moment. So I try to solve this starting a new thread
>>> >> where I initialised lwip and then start two listner threads for the
>>> >> two ports.
>>> >>
>>> >> This does not work however even if they each work perfect on there own.
>>> >>
>>> >> How should this be coded correctly? Any hints appreciated.
>>> >>
>>> >> My listner thread look like this
>>> >>
>>> >>
>>> >>
>>> >> ///////////////////////////////////////////////////////////////////////////////
>>> >> // taskVSCPListner
>>> >> //
>>> >>
>>> >> void taskVSCPListner( void *pvParameters )
>>> >> {
>>> >> struct netconn *pxVSCPListener; // Listens for VSCP connections
>>> >> struct netconn *pxNewConnection;
>>> >>
>>> >> // Create a new tcp connection handle for VSCP
>>> >> pxVSCPListener = netconn_new( NETCONN_TCP );
>>> >> netconn_bind( pxVSCPListener, NULL, VSCP_LEVEL2_TCP_PORT );
>>> >> netconn_listen( pxVSCPListener );
>>> >>
>>> >> // Loop forever
>>> >> for( ;; ) {
>>> >>
>>> >> // Wait for connection.
>>> >> pxNewConnection = netconn_accept( pxVSCPListener );
>>> >>
>>> >> if ( pxNewConnection != NULL ) {
>>> >>
>>> >> // Service connection.
>>> >> vProcessVSCPConnection( pxNewConnection );
>>> >>
>>> >> while( netconn_delete( pxNewConnection ) != ERR_OK ) {
>>> >> vTaskDelay( webSHORT_DELAY );
>>> >> }
>>> >>
>>> >> }
>>> >>
>>> >> }
>>> >> }
>>> >>
>>> >>
>>> >>
>>> >>
>>> >> ///////////////////////////////////////////////////////////////////////////////
>>> >> // taskHTTPListner
>>> >> //
>>> >>
>>> >> void taskHTTPListner( void *pvParameters )
>>> >> {
>>> >> struct netconn *pxHTTPListener; // Listens for HTTP connections
>>> >> struct netconn *pxNewConnection;
>>> >>
>>> >> // Create a new tcp connection handle for HTTP
>>> >> pxHTTPListener = netconn_new( NETCONN_TCP );
>>> >> netconn_bind( pxHTTPListener, NULL, webHTTP_PORT );
>>> >> netconn_listen( pxHTTPListener );
>>> >>
>>> >> // Create a new tcp connection handle for VSCP
>>> >> //pxVSCPListener = netconn_new( NETCONN_TCP );
>>> >> //netconn_bind( pxHTTPListener, NULL, VSCP_LEVEL2_TCP_PORT );
>>> >> //netconn_listen( pxVSCPListener );
>>> >>
>>> >> // Loop forever
>>> >> for( ;; ) {
>>> >>
>>> >> // Wait for connection.
>>> >> pxNewConnection = netconn_accept( pxHTTPListener );
>>> >>
>>> >> if ( pxNewConnection != NULL ) {
>>> >>
>>> >> // Service connection.
>>> >> vProcessConnection( pxNewConnection );
>>> >>
>>> >> while( netconn_delete( pxNewConnection ) != ERR_OK ) {
>>> >> vTaskDelay( webSHORT_DELAY );
>>> >> }
>>> >>
>>> >> }
>>> >>
>>> >> }
>>> >> }
>>> >>
>>> >> Cheers
>>> >> /Ake
>>> >>
>>> >>
>>> >> --
>>> >> ---
>>> >> Ake Hedman
>>> >> D of Scandinavia, http://www.dofscandinavia.com
>>> >>
>>> >>
>>> >> _______________________________________________
>>> >> lwip-users mailing list
>>> >> lwip-users@...
>>> >> http://lists.nongnu.org/mailman/listinfo/lwip-users
>>> >
>>> > ________________________________
>>> > It's the same Hotmail(R). If by "same" you mean up to 70% faster. Get
>>> > your
>>> > account now.
>>> > _______________________________________________
>>> > lwip-users mailing list
>>> > lwip-users@...
>>> > http://lists.nongnu.org/mailman/listinfo/lwip-users
>>> >
>>>
>>>
>>>
>>> --
>>> ---
>>> Ake Hedman
>>> D of Scandinavia, http://www.dofscandinavia.com
>>>
>>>
>>> _______________________________________________
>>> lwip-users mailing list
>>> lwip-users@...
>>> http://lists.nongnu.org/mailman/listinfo/lwip-users
>>
>> ________________________________
>> Send e-mail anywhere. No map, no compass. Get your Hotmail(R) account now.
>> _______________________________________________
>> lwip-users mailing list
>> lwip-users@...
>> http://lists.nongnu.org/mailman/listinfo/lwip-users
>>
>
>
>
> --
>  ---
> Ake Hedman
> D of Scandinavia, http://www.dofscandinavia.com
>

--

-- 
 ---
Ake Hedman
D of Scandinavia, http://www.dofscandinavia.com
Jonathan Larmour | 3 Jan 2009 22:28
Favicon

Re: DHCP renewing/ rebinding and on going connexions

PELISSIER Christophe wrote:
> Hi all,
> 
> i am using lwip V1.2 on a blackfin CPU. the lwip port has been made by
> Analog Device. I have not a long experience in lwip use. Looking at the
> DHCP client, i was wondering how on going connection are managed during
> an IP address change.
> 
> For example, during the IP renewing phase if the client receives a
> DHCPNAK (or never receives a DHCPACK), it should stop using its current
> IP address. The RFC2131adds on page 41 that it "MUST immediately stop
> any other network processing and requests network initialization
> parameters...".
> 
> In the current dhcp code, i have seen that in such cases a dhcp_release
> is performed. This shutdown the NETIF flags but for my understanding
> nothing is done for the connexions currently in use.

I believe lwIP behaves correctly here. Because the netif is set down, 
ip_route() will never match it. And ip_route() is always used before 
sending normal packets. lwIP doesn't have the complexity of a proper route 
cache and rightly so really. There is some small-scale support for 
"hardware hints" to save on ARP lookups which also saves the netif lookup, 
but ip_route is still called first in those cases too as far as I know.

If you can find somewhere where ip_route is not called before calling 
ip_output_if, then that might be an issue. Note that anything that results 
from an incoming packet on a netif is ok because ip_input() does not 
accept packets from interfaces which are marked down, apart from some 
special cases like DHCP and IGMP.

> Do i miss something? Is shutting down on going connection not required?
> That is the behaviour of opened sockets in such cases? If shutting down
> is required, does this action have to be performed by the stack? By the
> application level? If this action is related to application level, is
> there any call-back mechanism available to inform the application when
> these events are raised?
> 
> In the same way, RFC2131 says page 41, during a renewing phase,  "if
> the client is given a new network address, it MUST NOT continue using
> the previous network address and SHOULD notify le local users of the
> problem".

For the MUST NOT bit, again lwIP should be ok.

For the notification of local users, there is a netif status callback in 
lwIP 1.3 (NOT 1.2) you can use - enable LWIP_NETIF_STATUS_CALLBACK in 
lwipopts.h, and include/lwip/netif.h which has 
netif_set_status_callback(). netif_set_up() calls this callback, and that 
in turn is called when an interface is brought up or changes IP by DHCP. 
Of course you don't see the netif using the abstract sockets API, so you 
have to break the layering abstractions a bit here.

There is no official way in the sockets API to be informed of course. The 
word SHOULD is of course vital here. It's (obviously) not required. In 
fact it's a bit tricky to deal with: consider the case with multiple 
netifs, where the local socket is bound to 0.0.0.0 (i.e. any interface). 
For connection-less sockets it may still be possible to use another 
interface. That's why ip_route() is called of course. If packets genuinely 
can't be routed when there's something to be sent, then in lwIP, ERR_RTE 
is returned, which will be translated to EHOSTUNREACH for sockets API 
users. So it's not necessarily correct to go around shutting down sockets 
which had been using an interface which has now gone down or changed IP.

Alternatively for connection-oriented sockets and you try to send data[1] 
or have KEEPALIVEs on, all you can do is wait for the connection to 
eventually time out. That's not necessarily a big deal. After all, all you 
would probably want to do when informed the netif has changed IP is to 
shutdown() or close() any associated sockets anyway.

Hope this helps,

Jifl

[1] As per the other message I sent to the list, for some reason I can't 
find where retransmits do this, so if they don't at present, you may have 
to rely solely on KEEPALIVEs.
--

-- 
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.
------["The best things in life aren't things."]------      Opinions==mine
Rashmi C.V | 5 Jan 2009 05:50
Favicon

List of RFC's Supported

Hi,

 

Can I get the list of RFC’s supported and also with the reason why other RFC’s are not supported?

This would help us to know the if their would be any concerns if a device with LWIP is connected to the main stream network.

 

Thanks and Regards
Rashmi C V
Senior Software Engineer |KPIT Cummins Infosystems Limited | Board: +91 80 28391663 | Mobile: +91 9945431429 | www.kpitcummins.com

 

_______________________________________________
lwip-users mailing list
lwip-users@...
http://lists.nongnu.org/mailman/listinfo/lwip-users
PELISSIER Christophe | 5 Jan 2009 10:34
Picon
Favicon

RE: DHCP renewing/ rebinding and on going connexions

Ok! thanks for your information Jonathan.

Maybe it should be a good things for me to upgrade from lwip v1.2 to v1.3 rather than creating my own call-back
mechanisms in lwip v1.2.

Regards,
Christophe  

-----Original Message-----
From: lwip-users-bounces+c.pelissier=hager.fr@...
[mailto:lwip-users-bounces+c.pelissier=hager.fr@...]
On Behalf Of Jonathan Larmour
Sent: Saturday, January 03, 2009 10:29 PM
To: Mailing list for lwIP users
Subject: Re: [lwip-users] DHCP renewing/ rebinding and on going connexions

PELISSIER Christophe wrote:
> Hi all,
> 
> i am using lwip V1.2 on a blackfin CPU. the lwip port has been made by 
> Analog Device. I have not a long experience in lwip use. Looking at 
> the DHCP client, i was wondering how on going connection are managed 
> during an IP address change.
> 
> For example, during the IP renewing phase if the client receives a 
> DHCPNAK (or never receives a DHCPACK), it should stop using its 
> current IP address. The RFC2131adds on page 41 that it "MUST 
> immediately stop any other network processing and requests network 
> initialization parameters...".
> 
> In the current dhcp code, i have seen that in such cases a 
> dhcp_release is performed. This shutdown the NETIF flags but for my 
> understanding nothing is done for the connexions currently in use.

I believe lwIP behaves correctly here. Because the netif is set down,
ip_route() will never match it. And ip_route() is always used before sending normal packets. lwIP doesn't
have the complexity of a proper route cache and rightly so really. There is some small-scale support for
"hardware hints" to save on ARP lookups which also saves the netif lookup, but ip_route is still called
first in those cases too as far as I know.

If you can find somewhere where ip_route is not called before calling ip_output_if, then that might be an
issue. Note that anything that results from an incoming packet on a netif is ok because ip_input() does not
accept packets from interfaces which are marked down, apart from some special cases like DHCP and IGMP.

> Do i miss something? Is shutting down on going connection not required?
> That is the behaviour of opened sockets in such cases? If shutting 
> down is required, does this action have to be performed by the stack? 
> By the application level? If this action is related to application 
> level, is there any call-back mechanism available to inform the 
> application when these events are raised?
> 
> In the same way, RFC2131 says page 41, during a renewing phase,  "if 
> the client is given a new network address, it MUST NOT continue using 
> the previous network address and SHOULD notify le local users of the 
> problem".

For the MUST NOT bit, again lwIP should be ok.

For the notification of local users, there is a netif status callback in lwIP 1.3 (NOT 1.2) you can use -
enable LWIP_NETIF_STATUS_CALLBACK in lwipopts.h, and include/lwip/netif.h which has
netif_set_status_callback(). netif_set_up() calls this callback, and that in turn is called when an
interface is brought up or changes IP by DHCP. 
Of course you don't see the netif using the abstract sockets API, so you have to break the layering
abstractions a bit here.

There is no official way in the sockets API to be informed of course. The word SHOULD is of course vital here.
It's (obviously) not required. In fact it's a bit tricky to deal with: consider the case with multiple
netifs, where the local socket is bound to 0.0.0.0 (i.e. any interface). 
For connection-less sockets it may still be possible to use another interface. That's why ip_route() is
called of course. If packets genuinely can't be routed when there's something to be sent, then in lwIP,
ERR_RTE is returned, which will be translated to EHOSTUNREACH for sockets API users. So it's not
necessarily correct to go around shutting down sockets which had been using an interface which has now
gone down or changed IP.

Alternatively for connection-oriented sockets and you try to send data[1] or have KEEPALIVEs on, all you
can do is wait for the connection to eventually time out. That's not necessarily a big deal. After all, all
you would probably want to do when informed the netif has changed IP is to
shutdown() or close() any associated sockets anyway.

Hope this helps,

Jifl

[1] As per the other message I sent to the list, for some reason I can't find where retransmits do this, so if
they don't at present, you may have to rely solely on KEEPALIVEs.
--

-- 
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.
------["The best things in life aren't things."]------      Opinions==mine

_______________________________________________
lwip-users mailing list
lwip-users@...
http://lists.nongnu.org/mailman/listinfo/lwip-users

Gmane