diff --git a/source/nanoFramework.System.Net/DNS.cs b/source/nanoFramework.System.Net/DNS.cs
index 7f58e03..b5f8d10 100644
--- a/source/nanoFramework.System.Net/DNS.cs
+++ b/source/nanoFramework.System.Net/DNS.cs
@@ -39,30 +39,7 @@ public static IPHostEntry GetHostEntry(string hostNameOrAddress)
for (int i = 0; i < cAddresses; i++)
{
- byte[] address = addresses[i];
-
- SocketAddress sockAddress = new SocketAddress(address);
-
- AddressFamily family;
-
- //if(SystemInfo.IsBigEndian)
- ////{
- // family = (AddressFamily)((address[0] << 8) | address[1]);
- //}
- //else
- {
- family = (AddressFamily)((address[1] << 8) | address[0]);
- }
- //port address[2-3]
-
- if (family == AddressFamily.InterNetwork)
- {
- //This only works with IPv4 addresses
-
- uint ipAddr = (uint)((address[7] << 24) | (address[6] << 16) | (address[5] << 8) | (address[4]));
-
- ipAddresses[i] = new IPAddress((long)ipAddr);
- }
+ ipAddresses[i] = new IPAddress(addresses[i]);
}
ipHostEntry.hostName = canonicalName;
diff --git a/source/nanoFramework.System.Net/IPAddress.cs b/source/nanoFramework.System.Net/IPAddress.cs
index fc4207b..de65da8 100644
--- a/source/nanoFramework.System.Net/IPAddress.cs
+++ b/source/nanoFramework.System.Net/IPAddress.cs
@@ -75,12 +75,13 @@ public IPAddress(long newAddress)
///
public IPAddress(byte[] address)
{
- if (address.Length == IPv4AddressBytes)
+ if (address[0] == (byte)AddressFamily.InterNetwork)
{
_family = AddressFamily.InterNetwork;
- _address = ((address[3] << 24 | address[2] << 16 | address[1] << 8 | address[0]) & 0x0FFFFFFFF);
+ // need to offset address by 4 (1st are family, 2nd are port
+ _address = ((address[3 + 4] << 24 | address[2 + 4] << 16 | address[1 + 4] << 8 | address[0 + 4]) & 0x0FFFFFFFF);
}
- else
+ else if (address[0] == (byte)AddressFamily.InterNetworkV6)
{
_family = AddressFamily.InterNetworkV6;
@@ -89,6 +90,11 @@ public IPAddress(byte[] address)
_numbers[i] = (ushort)(address[i * 2] * 256 + address[i * 2 + 1]);
}
}
+ else
+ {
+ // unsupported address family
+ throw new NotSupportedException();
+ }
}
///
diff --git a/source/nanoFramework.System.Net/Properties/AssemblyInfo.cs b/source/nanoFramework.System.Net/Properties/AssemblyInfo.cs
index 1ee1e36..1e41ea3 100644
--- a/source/nanoFramework.System.Net/Properties/AssemblyInfo.cs
+++ b/source/nanoFramework.System.Net/Properties/AssemblyInfo.cs
@@ -12,7 +12,7 @@
////////////////////////////////////////////////////////////////
// update this whenever the native assembly signature changes //
-[assembly: AssemblyNativeVersion("1.1.0.0")]
+[assembly: AssemblyNativeVersion("1.1.1.0")]
////////////////////////////////////////////////////////////////
// Setting ComVisible to false makes the types in this assembly not visible
diff --git a/source/nanoFramework.System.Net/Sockets/Socket.cs b/source/nanoFramework.System.Net/Sockets/Socket.cs
index 1bf6df2..d65457d 100644
--- a/source/nanoFramework.System.Net/Sockets/Socket.cs
+++ b/source/nanoFramework.System.Net/Sockets/Socket.cs
@@ -123,23 +123,20 @@ private EndPoint GetEndPoint(bool fLocal)
m_localEndPoint = new IPEndPoint(IPAddress.Any, 0);
}
- byte[] address = null;
+ EndPoint endPoint = null;
if (fLocal)
{
- NativeSocket.getsockname(this, out address);
+ NativeSocket.getsockname(this, out endPoint);
}
else
{
- NativeSocket.getpeername(this, out address);
+ NativeSocket.getpeername(this, out endPoint);
}
- SocketAddress socketAddress = new SocketAddress(address);
- ep = m_localEndPoint.Create(socketAddress);
-
if (fLocal)
{
- m_localEndPoint = ep;
+ m_localEndPoint = endPoint;
}
return ep;
diff --git a/source/nanoFramework.System.Net/Sockets/SocketsNative.cs b/source/nanoFramework.System.Net/Sockets/SocketsNative.cs
index 79e67b2..5bd405d 100644
--- a/source/nanoFramework.System.Net/Sockets/SocketsNative.cs
+++ b/source/nanoFramework.System.Net/Sockets/SocketsNative.cs
@@ -41,16 +41,16 @@ internal class NativeSocket
public static extern void shutdown(object socket, int how, out int err);
[MethodImpl(MethodImplOptions.InternalCall)]
- public static extern int sendto(object socket, byte[] buf, int offset, int count, int flags, int timeout_ms, EndPoint address);
+ public static extern int sendto(object socket, byte[] buf, int offset, int count, int flags, int timeout_ms, EndPoint endPoint);
[MethodImpl(MethodImplOptions.InternalCall)]
- public static extern int recvfrom(object socket, byte[] buf, int offset, int count, int flags, int timeout_ms, ref EndPoint address);
+ public static extern int recvfrom(object socket, byte[] buf, int offset, int count, int flags, int timeout_ms, ref EndPoint endPoint);
[MethodImpl(MethodImplOptions.InternalCall)]
- public static extern void getpeername(object socket, out byte[] address);
+ public static extern void getpeername(object socket, out EndPoint endPoint);
[MethodImpl(MethodImplOptions.InternalCall)]
- public static extern void getsockname(object socket, out byte[] address);
+ public static extern void getsockname(object socket, out EndPoint endPoint);
[MethodImpl(MethodImplOptions.InternalCall)]
public static extern void getsockopt(object socket, int level, int optname, byte[] optval);
diff --git a/source/version.json b/source/version.json
index 3d454d0..0467bbb 100644
--- a/source/version.json
+++ b/source/version.json
@@ -1,6 +1,6 @@
{
"$schema": "https://raw.githubusercontent.com/AArnott/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
- "version": "1.1.0-preview.{height}",
+ "version": "1.1.1-preview.{height}",
"release": {
"branchName" : "release-v{version}",
"versionIncrement" : "minor",