lwip-users
[Top][All Lists]
Advanced

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

Re: [lwip-users] How to have two different sockets for IPv4 and IPv6


From: Ivan Delamer
Subject: Re: [lwip-users] How to have two different sockets for IPv4 and IPv6
Date: Wed, 08 Apr 2015 10:10:13 -0600

I don't use the socket API but as far as I can remember, all you need is one socket listening on IPv6 ANY address. This will accept IPv4 connections as well by default. It can also be disabled.

If there is no predefined sin6 address for ANY, your procedure of setting it to 0 is correct.

Somebody about a year or two ago had made sure this was working. Is it not working for you?

Cheers
Ivan



Date: Wed, 8 Apr 2015 06:15:08 -0700 (MST)
From: Mohsin <address@hidden>
To: address@hidden
Subject: [lwip-users] How to have two different sockets for IPv4 and
        IPv6
Message-ID: <address@hidden>
Content-Type: text/plain; charset=us-ascii

Hi,

I am trying to write a web server that listens on both IPv4 and IPv6
addresses. Although, only one implementation at a time works fine. However, the code that I wrote for both simulateniously doesn't work. I mean I'm creating two diff webserver tasks for IPv4 and IPv6. The socket for both
AF_INET6 and AF_INET and binding it with port=80 which is as follows:

//webserver_task_IPv4
iStatus = socket( AF_INET, SOCK_STREAM, 0 );
sin.sin_family = AF_INET;
sin.sin_len = sizeof(sin);
sin.sin_addr.s_addr = htonl(INADDR_ANY);
sin.sin_port = HTTP_PORT_NUMBER;               //port = 80
memset(&(sin.sin_zero), '\0', sizeof(sin.sin_zero));

//webserver_task_IPv6
iStatus = socket( AF_INET6, SOCK_STREAM, 0 );
sin.sin6_family = AF_INET6;
sin.sin6_len = sizeof(sin);
memset(&(sin.sin6_addr), 0, sizeof(sin.sin6_addr));
sin.sin6_port = HTTP_PORT_NUMBER;               //port = 80


Actually I'm looking for "in6addr_any" for filling IPv6 ANY Address into
IPv6 socket case but can't find anywhere in the stack and hence used
memset() to set sin6_addr to 0. So is there any replacement variable defined
for it in the stack?

Both above tasks works fine when implemented one at a time.

Can anyone please suggest proper socket binding that can listen for both
IPv4 and IPv6 at the same time.

Any help would be highly appreciated.

Thanks & regards,
Mohsin Kesarani





reply via email to

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