pull/119/head
dahall 2020-03-25 17:38:41 -06:00
parent cba24dd268
commit 969837d959
1 changed files with 7 additions and 1 deletions

View File

@ -2582,7 +2582,7 @@ namespace Vanara.PInvoke
public SOCKADDR(IPAddress ipAddress) : this(ipAddress.GetAddressBytes()) { }
/// <summary>Initializes a new instance of the <see cref="SOCKADDR"/> class.</summary>
/// <param name="socketAddress">The socket address.</param>
/// <param name="endPoint">The socket address.</param>
public SOCKADDR(IPEndPoint endPoint) : this(endPoint.Address.GetAddressBytes(), (ushort)endPoint.Port) { }
/// <summary>Gets an instance that represents an empty address.</summary>
@ -2596,6 +2596,12 @@ namespace Vanara.PInvoke
/// <value>The address family.</value>
public ADDRESS_FAMILY sa_family => (ADDRESS_FAMILY)handle.ToStructure<ushort>();
/// <summary>Allocates from unmanaged memory sufficient memory to hold an object of type T.</summary>
/// <typeparam name="T">Native type</typeparam>
/// <param name="value">The value.</param>
/// <returns><see cref="SOCKADDR"/> object to an native (unmanaged) memory block the size of T.</returns>
public static SOCKADDR CreateFromStructure<T>(T value = default) => new SOCKADDR(InteropExtensions.MarshalToPtr(value, mm.AllocMem, out int s), true, s);
/// <summary>Performs an explicit conversion from <see cref="SOCKADDR"/> to <see cref="SOCKADDR_IN"/>.</summary>
/// <param name="addr">The address.</param>
/// <returns>The resulting <see cref="SOCKADDR_IN"/> instance from the conversion.</returns>