Monday, October 05, 2020

LuaSocket, Mac vs. Linux - further info...

From my previous blog post, see the following

https://stackoverflow.com/questions/51911564/cannot-bind-socket-to-port-in-both-ipv4-and-ipv6

It seems likely this is the problem... although I haven't tested it yet.


A fragment:

IPV6_V6ONLY (since Linux 2.4.21 and 2.6) If this flag is set to true (nonzero), then the socket is restricted to sending and receiving IPv6 packets only. In this case, an IPv4 and an IPv6 application can bind to a single port at the same time. If this flag is set to false (zero), then the socket can be used to send and receive packets to and from an IPv6 address or an IPv4-mapped IPv6 address.

The argument is a pointer to a boolean value in an integer.

The default value for this flag is defined by the contents of the file /proc/sys/net/ipv6/bindv6only. The default value for that file is 0 (false).

Taken from man 7 ipv6

 

 

Also see: 

https://stackoverflow.com/questions/1618240/how-to-support-both-ipv4-and-ipv6-connections

The best approach is to create an IPv6 server socket that can also accept IPv4 connections. To do so, create a regular IPv6 socket, turn off the socket option IPV6_V6ONLY, bind it to the "any" address, and start receiving. IPv4 addresses will be presented as IPv6 addresses, in the IPv4-mapped format.
The major difference across systems is whether IPV6_V6ONLY is a) available, and b) turned on or off by default. It is turned off by default on Linux (i.e. allowing dual-stack sockets without setsockopt), and is turned on on most other systems.
In addition, the IPv6 stack on Windows XP doesn't support that option. In these cases, you will need to create two separate server sockets, and place them into select or into multiple threads.


NOTE: Then commenter's mention IPV6_V6ONLY is off by default on Linux is wrong - it depends on the configuration on the distribution.

  




1 Comments:

Anonymous best erectile dysfunction pills said...

This site certainly has all the information I wanted about this subject and didn't know who to ask.

12:55 pm  

Post a Comment

<< Home

Newer›  ‹Older