I just updated only on CodePlex (for now) M2Mqtt library (version 22.214.171.124), adding the automatic detection of any IPv6 address to connect.
To determine the address class (AddressFamily), I implemented the '"Extension Method" GetAddressFamily() for the IPAddress class through the static class IPAddressUtility, necessary only because the. NET Micro Framework does not itself provide the property AddressFamily the IPAddress class. In fact, in the case of full / compact. Net Framework is returned that property while in the case of. NET Micro Framework is done by a simple search of the ":" character (separator in IPv6 addresses).
1: public static AddressFamily GetAddressFamily(this IPAddress ipAddress)
3: #if (!MF_FRAMEWORK_VERSION_V4_2 && !MF_FRAMEWORK_VERSION_V4_3)
4: return ipAddress.AddressFamily;
6: return (ipAddress.ToString().IndexOf(':') != -1) ?
7: AddressFamily.InterNetworkV6 : AddressFamily.InterNetwork;
In this way, at the time of the creation of the socket, it is automatically set to the correct address family from the address to connect to.
1: this.socket = new Socket(this.remoteIpAddress.GetAddressFamily(),
2: SocketType.Stream, ProtocolType.Tcp);
Little change .... very useful!
Hi Paolo, Test message to validate email notification for new comment. Posted on Oct. 13 @ 9:48 PM Pacific time
View this page in another language: