Introduced `WSRESULT` as standard error for all WinSock functions -- similar to NTStatus

pull/303/head
dahall 2022-07-11 10:42:39 -06:00
parent ea1c63e76e
commit 7791d773e4
5 changed files with 614 additions and 137 deletions

View File

@ -1,33 +1,510 @@
using System;
using System.Net.Sockets;
using System.Runtime.InteropServices;
using System.Security;
namespace Vanara.PInvoke
namespace Vanara.PInvoke;
public static partial class Ws2_32
{
public static partial class Ws2_32
/// <summary>A WinSock2 result. Some functions can interpret the result from a simple failure (SOCKET_ERROR) to the actual error.</summary>
[StructLayout(LayoutKind.Sequential, Pack = 4)]
[PInvokeData("winsock2.h")]
public struct WSRESULT : IComparable, IComparable<WSRESULT>, IEquatable<WSRESULT>, IEquatable<int>, IEquatable<SocketError>, IConvertible, IErrorProvider
{
internal readonly int _value;
/// <summary>Initializes a new instance of the <see cref="WSRESULT"/> structure.</summary>
/// <param name="rawValue">The raw WSRESULT value.</param>
public WSRESULT(int rawValue) => _value = rawValue;
/// <summary>Gets a value indicating whether this <see cref="WSRESULT"/> is a failure (Severity bit 31 equals 1).</summary>
/// <value><c>true</c> if failed; otherwise, <c>false</c>.</value>
public bool Failed => _value != 0;
/// <summary>Gets a value indicating whether this <see cref="WSRESULT"/> is a success (Severity bit 31 equals 0).</summary>
/// <value><c>true</c> if succeeded; otherwise, <c>false</c>.</value>
public bool Succeeded => _value == 0;
/// <summary>Performs an explicit conversion from <see cref="WSRESULT"/> to <see cref="HRESULT"/>.</summary>
/// <param name="value">The value.</param>
/// <returns>The resulting <see cref="HRESULT"/> instance from the conversion.</returns>
public static explicit operator HRESULT(WSRESULT value) => value.ToHRESULT();
/// <summary>Performs an explicit conversion from <see cref="WSRESULT"/> to <see cref="int"/>.</summary>
/// <param name="value">The value.</param>
/// <returns>The result of the conversion.</returns>
public static explicit operator int(WSRESULT value) => value._value;
/// <summary>Performs an explicit conversion from <see cref="WSRESULT"/> to <see cref="SocketError"/>.</summary>
/// <param name="value">The value.</param>
/// <returns>The result of the conversion.</returns>
public static explicit operator SocketError(WSRESULT value) => (SocketError)value._value;
/// <summary>Performs an implicit conversion from <see cref="int"/> to <see cref="WSRESULT"/>.</summary>
/// <param name="value">The value.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator WSRESULT(int value) => new(value);
/// <summary>Performs an implicit conversion from <see cref="SocketError"/> to <see cref="WSRESULT"/>.</summary>
/// <param name="value">The value.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator WSRESULT(SocketError value) => new((int)value);
/// <summary>Implements the operator !=.</summary>
/// <param name="hrLeft">The first <see cref="WSRESULT"/>.</param>
/// <param name="hrRight">The second <see cref="WSRESULT"/>.</param>
/// <returns>The result of the operator.</returns>
public static bool operator !=(WSRESULT hrLeft, WSRESULT hrRight) => !(hrLeft == hrRight);
/// <summary>Implements the operator !=.</summary>
/// <param name="hrLeft">The first <see cref="WSRESULT"/>.</param>
/// <param name="hrRight">The second <see cref="int"/>.</param>
/// <returns>The result of the operator.</returns>
public static bool operator !=(WSRESULT hrLeft, int hrRight) => !(hrLeft == hrRight);
/// <summary>Implements the operator ==.</summary>
/// <param name="hrLeft">The first <see cref="WSRESULT"/>.</param>
/// <param name="hrRight">The second <see cref="WSRESULT"/>.</param>
/// <returns>The result of the operator.</returns>
public static bool operator ==(WSRESULT hrLeft, WSRESULT hrRight) => hrLeft.Equals(hrRight);
/// <summary>Implements the operator ==.</summary>
/// <param name="hrLeft">The first <see cref="WSRESULT"/>.</param>
/// <param name="hrRight">The second <see cref="int"/>.</param>
/// <returns>The result of the operator.</returns>
public static bool operator ==(WSRESULT hrLeft, int hrRight) => hrLeft.Equals(hrRight);
/// <summary>
/// Throws an appropriate exception if <paramref name="err"/> is a failure. If the value of <paramref name="err"/> equals <see
/// cref="SocketError.SocketError"/> (-1 or SOCKET_ERROR), then <see cref="WSAGetLastError"/> is called to retrive the actual error.
/// If the supplied raw WSRESULT value represents a failure, throw the associated <see cref="Exception"/> with the optionally
/// supplied message.
/// </summary>
/// <param name="err">The <see cref="SocketError"/> value to process.</param>
public static void ThrowIfFailed(this SocketError err) { var ex = err.GetException(); if (ex is not null) throw ex; }
/// <param name="value">The 32-bit raw WSRESULT value.</param>
/// <param name="message">The optional message to assign to the <see cref="Exception"/>.</param>
public static void ThrowIfFailed(int value, string message = null) => new WSRESULT(value).ThrowIfFailed(message);
/// <summary>Throws the last error if the predicate delegate returns <see langword="true"/>.</summary>
/// <typeparam name="T">The type of the value to evaluate.</typeparam>
/// <param name="value">The value to check.</param>
/// <param name="valueIsFailure">The delegate which returns <see langword="true"/> on failure.</param>
/// <param name="message">The message.</param>
/// <returns>The <paramref name="value"/> passed in on success.</returns>
public static T ThrowLastErrorIf<T>(T value, Func<T, bool> valueIsFailure, string message = null)
{
if (valueIsFailure(value))
GetLastError().ThrowIfFailed(message);
return value;
}
/// <summary>Throws the last error if the function returns <see langword="false"/>.</summary>
/// <param name="value">The value to check.</param>
public static void ThrowLastErrorIfFalse(bool value) { if (!value) throw WSAGetLastError().GetException(); }
/// <param name="message">The message.</param>
public static bool ThrowLastErrorIfFalse(bool value, string message = null) => ThrowLastErrorIf(value, v => !v, message);
/// <summary>Throws the last error if the value is an invalid handle.</summary>
/// <param name="value">The SafeHandle to check.</param>
/// <param name="message">The message.</param>
public static T ThrowLastErrorIfInvalid<T>(T value, string message = null) where T : SafeHandle => ThrowLastErrorIf(value, v => v.IsInvalid, message);
/// <summary>Compares the current object with another object of the same type.</summary>
/// <param name="other">An object to compare with this object.</param>
/// <returns>
/// A value that indicates the relative order of the objects being compared. The return value has the following
/// meanings: Value Meaning Less than zero This object is less than the <paramref name="other"/> parameter.Zero This object is equal
/// to <paramref name="other"/>. Greater than zero This object is greater than <paramref name="other"/>.
/// </returns>
public int CompareTo(WSRESULT other) => _value.CompareTo(other._value);
/// <summary>
/// Gets the .NET <see cref="Exception"/> associated with the <see cref="SocketError"/> value and optionally adds the supplied message.
/// Compares the current instance with another object of the same type and returns an integer that indicates whether the current
/// instance precedes, follows, or occurs in the same position in the sort order as the other object.
/// </summary>
/// <param name="err">The <see cref="SocketError"/> value to process.</param>
/// <returns>The associated <see cref="Exception"/> or <see langword="null"/> if this <see cref="SocketError"/> is not a failure.</returns>
/// <param name="obj">An object to compare with this instance.</param>
/// <returns>
/// A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less
/// than zero This instance precedes <paramref name="obj"/> in the sort order. Zero This instance occurs in the same position in the
/// sort order as <paramref name="obj"/> . Greater than zero This instance follows <paramref name="obj"/> in the sort order.
/// </returns>
public int CompareTo(object obj) => obj switch
{
WSRESULT r => CompareTo(r),
int i => i.CompareTo(_value),
SocketError e => e.CompareTo((SocketError)_value),
IErrorProvider e => ToHRESULT().CompareTo(e.ToHRESULT()),
_ => _value.CompareTo(obj)
};
/// <summary>Indicates whether the current object is equal to an <see cref="int"/>.</summary>
/// <param name="other">An object to compare with this object.</param>
/// <returns>true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.</returns>
public bool Equals(int other) => other == _value;
/// <summary>Determines whether the specified <see cref="object"/>, is equal to this instance.</summary>
/// <param name="obj">The <see cref="object"/> to compare with this instance.</param>
/// <returns><c>true</c> if the specified <see cref="object"/> is equal to this instance; otherwise, <c>false</c>.</returns>
public override bool Equals(object obj) => obj switch
{
null => false,
WSRESULT r => Equals(r),
int i => Equals(i),
SocketError e => Equals(e),
IErrorProvider e => ToHRESULT().Equals(e.ToHRESULT()),
IConvertible c => Equals(c.ToInt32(null)),
_ => base.Equals(obj)
};
/// <summary>Indicates whether the current object is equal to an <see cref="SocketError"/>.</summary>
/// <param name="other">An object to compare with this object.</param>
/// <returns>true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.</returns>
public bool Equals(SocketError other) => (int)other == _value;
/// <summary>Indicates whether the current object is equal to another object of the same type.</summary>
/// <param name="other">An object to compare with this object.</param>
/// <returns>true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.</returns>
public bool Equals(WSRESULT other) => other._value == _value;
/// <summary>Gets the .NET <see cref="Exception"/> associated with the WSRESULT value and optionally adds the supplied message.</summary>
/// <param name="message">The optional message to assign to the <see cref="Exception"/>.</param>
/// <returns>The associated <see cref="Exception"/> or <c>null</c> if this WSRESULT is not a failure.</returns>
[SecurityCritical, SecuritySafeCritical]
public static Exception GetException(this SocketError err) => err switch
public Exception GetException(string message = null) => _value switch
{
0 => null,
SocketError.SocketError => new SocketException((int)WSAGetLastError()),
_ => new SocketException((int)err)
SOCKET_ERROR => new SocketException((int)GetLastError()),
_ => new SocketException(_value)
};
/// <summary>Returns a hash code for this instance.</summary>
/// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.</returns>
public override int GetHashCode() => _value;
/// <summary>Gets the last error.</summary>
/// <returns>The last error.</returns>
[SecurityCritical]
[System.Diagnostics.DebuggerStepThrough]
public static WSRESULT GetLastError() => WSAGetLastError();
/// <summary>
/// If this <see cref="WSRESULT"/> represents a failure, throw the associated <see cref="Exception"/> with the optionally supplied message.
/// </summary>
/// <param name="message">The optional message to assign to the <see cref="Exception"/>.</param>
[SecurityCritical]
[SecuritySafeCritical]
public void ThrowIfFailed(string message = null)
{
Exception exception = GetException(message);
if (exception is not null)
throw exception;
}
/// <summary>Converts this error to an <see cref="HRESULT"/>.</summary>
/// <returns>An equivalent <see cref="HRESULT"/>.</returns>
public HRESULT ToHRESULT() => HRESULT.HRESULT_FROM_WIN32(unchecked((uint)(_value == SOCKET_ERROR ? GetLastError()._value : _value)));
/// <summary>Returns a <see cref="string"/> that represents this instance.</summary>
/// <returns>A <see cref="string"/> that represents this instance.</returns>
public override string ToString() => StaticFieldValueHash.TryGetFieldName<WSRESULT, int>(_value, out var err) ? err : ToHRESULT().ToString();
TypeCode IConvertible.GetTypeCode() => _value.GetTypeCode();
bool IConvertible.ToBoolean(IFormatProvider provider) => Succeeded;
byte IConvertible.ToByte(IFormatProvider provider) => ((IConvertible)_value).ToByte(provider);
char IConvertible.ToChar(IFormatProvider provider) => throw new NotSupportedException();
DateTime IConvertible.ToDateTime(IFormatProvider provider) => throw new NotSupportedException();
decimal IConvertible.ToDecimal(IFormatProvider provider) => ((IConvertible)_value).ToDecimal(provider);
double IConvertible.ToDouble(IFormatProvider provider) => ((IConvertible)_value).ToDouble(provider);
short IConvertible.ToInt16(IFormatProvider provider) => ((IConvertible)_value).ToInt16(provider);
int IConvertible.ToInt32(IFormatProvider provider) => _value;
long IConvertible.ToInt64(IFormatProvider provider) => ((IConvertible)_value).ToInt64(provider);
sbyte IConvertible.ToSByte(IFormatProvider provider) => ((IConvertible)_value).ToSByte(provider);
float IConvertible.ToSingle(IFormatProvider provider) => ((IConvertible)_value).ToSingle(provider);
string IConvertible.ToString(IFormatProvider provider) => ToString();
object IConvertible.ToType(Type conversionType, IFormatProvider provider) =>
((IConvertible)_value).ToType(conversionType, provider);
ushort IConvertible.ToUInt16(IFormatProvider provider) => ((IConvertible)unchecked((uint)_value)).ToUInt16(provider);
uint IConvertible.ToUInt32(IFormatProvider provider) => unchecked((uint)_value);
ulong IConvertible.ToUInt64(IFormatProvider provider) => ((IConvertible)unchecked((uint)_value)).ToUInt64(provider);
/// <summary>A blocking operation was interrupted by a call to WSACancelBlockingCall.</summary>
public const int WSAEINTR = 0x00002714;
/// <summary>The file handle supplied is not valid.</summary>
public const int WSAEBADF = 0x00002719;
/// <summary>An attempt was made to access a socket in a way forbidden by its access permissions.</summary>
public const int WSAEACCES = 0x0000271D;
/// <summary>The system detected an invalid pointer address in attempting to use a pointer argument in a call.</summary>
public const int WSAEFAULT = 0x0000271E;
/// <summary>An invalid argument was supplied.</summary>
public const int WSAEINVAL = 0x00002726;
/// <summary>Too many open sockets.</summary>
public const int WSAEMFILE = 0x00002728;
/// <summary>A nonblocking socket operation could not be completed immediately.</summary>
public const int WSAEWOULDBLOCK = 0x00002733;
/// <summary>A blocking operation is currently executing.</summary>
public const int WSAEINPROGRESS = 0x00002734;
/// <summary>An operation was attempted on a nonblocking socket that already had an operation in progress.</summary>
public const int WSAEALREADY = 0x00002735;
/// <summary>An operation was attempted on something that is not a socket.</summary>
public const int WSAENOTSOCK = 0x00002736;
/// <summary>A required address was omitted from an operation on a socket.</summary>
public const int WSAEDESTADDRREQ = 0x00002737;
/// <summary>A message sent on a datagram socket was larger than the internal message buffer or some other network limit, or the buffer used to receive a datagram into was smaller than the datagram itself.</summary>
public const int WSAEMSGSIZE = 0x00002738;
/// <summary>A protocol was specified in the socket function call that does not support the semantics of the socket type requested.</summary>
public const int WSAEPROTOTYPE = 0x00002739;
/// <summary>An unknown, invalid, or unsupported option or level was specified in a getsockopt or setsockopt call.</summary>
public const int WSAENOPROTOOPT = 0x0000273A;
/// <summary>The requested protocol has not been configured into the system, or no implementation for it exists.</summary>
public const int WSAEPROTONOSUPPORT = 0x0000273B;
/// <summary>The support for the specified socket type does not exist in this address family.</summary>
public const int WSAESOCKTNOSUPPORT = 0x0000273C;
/// <summary>The attempted operation is not supported for the type of object referenced.</summary>
public const int WSAEOPNOTSUPP = 0x0000273D;
/// <summary>The protocol family has not been configured into the system or no implementation for it exists.</summary>
public const int WSAEPFNOSUPPORT = 0x0000273E;
/// <summary>An address incompatible with the requested protocol was used.</summary>
public const int WSAEAFNOSUPPORT = 0x0000273F;
/// <summary>Only one usage of each socket address (protocol/network address/port) is normally permitted.</summary>
public const int WSAEADDRINUSE = 0x00002740;
/// <summary>The requested address is not valid in its context.</summary>
public const int WSAEADDRNOTAVAIL = 0x00002741;
/// <summary>A socket operation encountered a dead network.</summary>
public const int WSAENETDOWN = 0x00002742;
/// <summary>A socket operation was attempted to an unreachable network.</summary>
public const int WSAENETUNREACH = 0x00002743;
/// <summary>The connection has been broken due to keep-alive activity detecting a failure while the operation was in progress.</summary>
public const int WSAENETRESET = 0x00002744;
/// <summary>An established connection was aborted by the software in your host machine.</summary>
public const int WSAECONNABORTED = 0x00002745;
/// <summary>An existing connection was forcibly closed by the remote host.</summary>
public const int WSAECONNRESET = 0x00002746;
/// <summary>An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.</summary>
public const int WSAENOBUFS = 0x00002747;
/// <summary>A connect request was made on an already connected socket.</summary>
public const int WSAEISCONN = 0x00002748;
/// <summary>A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied.</summary>
public const int WSAENOTCONN = 0x00002749;
/// <summary>A request to send or receive data was disallowed because the socket had already been shut down in that direction with a previous shutdown call.</summary>
public const int WSAESHUTDOWN = 0x0000274A;
/// <summary>Too many references to a kernel object.</summary>
public const int WSAETOOMANYREFS = 0x0000274B;
/// <summary>A connection attempt failed because the connected party did not properly respond after a period of time, or the established connection failed because the connected host failed to respond.</summary>
public const int WSAETIMEDOUT = 0x0000274C;
/// <summary>No connection could be made because the target machine actively refused it.</summary>
public const int WSAECONNREFUSED = 0x0000274D;
/// <summary>Cannot translate name.</summary>
public const int WSAELOOP = 0x0000274E;
/// <summary>Name or name component was too long.</summary>
public const int WSAENAMETOOLONG = 0x0000274F;
/// <summary>A socket operation failed because the destination host was down.</summary>
public const int WSAEHOSTDOWN = 0x00002750;
/// <summary>A socket operation was attempted to an unreachable host.</summary>
public const int WSAEHOSTUNREACH = 0x00002751;
/// <summary>Cannot remove a directory that is not empty.</summary>
public const int WSAENOTEMPTY = 0x00002752;
/// <summary>A Windows Sockets implementation might have a limit on the number of applications that can use it simultaneously.</summary>
public const int WSAEPROCLIM = 0x00002753;
/// <summary>Ran out of quota.</summary>
public const int WSAEUSERS = 0x00002754;
/// <summary>Ran out of disk quota.</summary>
public const int WSAEDQUOT = 0x00002755;
/// <summary>File handle reference is no longer available.</summary>
public const int WSAESTALE = 0x00002756;
/// <summary>Item is not available locally.</summary>
public const int WSAEREMOTE = 0x00002757;
/// <summary>WSAStartup cannot function at this time because the underlying system it uses to provide network services is currently unavailable.</summary>
public const int WSASYSNOTREADY = 0x0000276B;
/// <summary>The Windows Sockets version requested is not supported.</summary>
public const int WSAVERNOTSUPPORTED = 0x0000276C;
/// <summary>Either the application has not called WSAStartup, or WSAStartup failed.</summary>
public const int WSANOTINITIALISED = 0x0000276D;
/// <summary>Returned by WSARecv or WSARecvFrom to indicate that the remote party has initiated a graceful shutdown sequence.</summary>
public const int WSAEDISCON = 0x00002775;
/// <summary>No more results can be returned by WSALookupServiceNext.</summary>
public const int WSAENOMORE = 0x00002776;
/// <summary>A call to WSALookupServiceEnd was made while this call was still processing. The call has been canceled.</summary>
public const int WSAECANCELLED = 0x00002777;
/// <summary>The procedure call table is invalid.</summary>
public const int WSAEINVALIDPROCTABLE = 0x00002778;
/// <summary>The requested service provider is invalid.</summary>
public const int WSAEINVALIDPROVIDER = 0x00002779;
/// <summary>The requested service provider could not be loaded or initialized.</summary>
public const int WSAEPROVIDERFAILEDINIT = 0x0000277A;
/// <summary>A system call that should never fail has failed.</summary>
public const int WSASYSCALLFAILURE = 0x0000277B;
/// <summary>No such service is known. The service cannot be found in the specified namespace.</summary>
public const int WSASERVICE_NOT_FOUND = 0x0000277C;
/// <summary>The specified class was not found.</summary>
public const int WSATYPE_NOT_FOUND = 0x0000277D;
/// <summary>No more results can be returned by WSALookupServiceNext.</summary>
public const int WSA_E_NO_MORE = 0x0000277E;
/// <summary>A call to WSALookupServiceEnd was made while this call was still processing. The call has been canceled.</summary>
public const int WSA_E_CANCELLED = 0x0000277F;
/// <summary>A database query failed because it was actively refused.</summary>
public const int WSAEREFUSED = 0x00002780;
/// <summary>No such host is known.</summary>
public const int WSAHOST_NOT_FOUND = 0x00002AF9;
/// <summary>This is usually a temporary error during host name resolution and means that the local server did not receive a response from an authoritative server.</summary>
public const int WSATRY_AGAIN = 0x00002AFA;
/// <summary>A nonrecoverable error occurred during a database lookup.</summary>
public const int WSANO_RECOVERY = 0x00002AFB;
/// <summary>The requested name is valid, but no data of the requested type was found.</summary>
public const int WSANO_DATA = 0x00002AFC;
/// <summary>At least one reserve has arrived.</summary>
public const int WSA_QOS_RECEIVERS = 0x00002AFD;
/// <summary>At least one path has arrived.</summary>
public const int WSA_QOS_SENDERS = 0x00002AFE;
/// <summary>There are no senders.</summary>
public const int WSA_QOS_NO_SENDERS = 0x00002AFF;
/// <summary>There are no receivers.</summary>
public const int WSA_QOS_NO_RECEIVERS = 0x00002B00;
/// <summary>Reserve has been confirmed.</summary>
public const int WSA_QOS_REQUEST_CONFIRMED = 0x00002B01;
/// <summary>Error due to lack of resources.</summary>
public const int WSA_QOS_ADMISSION_FAILURE = 0x00002B02;
/// <summary>Rejected for administrative reasons - bad credentials.</summary>
public const int WSA_QOS_POLICY_FAILURE = 0x00002B03;
/// <summary>Unknown or conflicting style.</summary>
public const int WSA_QOS_BAD_STYLE = 0x00002B04;
/// <summary>There is a problem with some part of the filterspec or provider-specific buffer in general.</summary>
public const int WSA_QOS_BAD_OBJECT = 0x00002B05;
/// <summary>There is a problem with some part of the flowspec.</summary>
public const int WSA_QOS_TRAFFIC_CTRL_ERROR = 0x00002B06;
/// <summary>General quality of serve (QOS) error.</summary>
public const int WSA_QOS_GENERIC_ERROR = 0x00002B07;
/// <summary>An invalid or unrecognized service type was found in the flowspec.</summary>
public const int WSA_QOS_ESERVICETYPE = 0x00002B08;
/// <summary>An invalid or inconsistent flowspec was found in the QOS structure.</summary>
public const int WSA_QOS_EFLOWSPEC = 0x00002B09;
/// <summary>Invalid QOS provider-specific buffer.</summary>
public const int WSA_QOS_EPROVSPECBUF = 0x00002B0A;
/// <summary>An invalid QOS filter style was used.</summary>
public const int WSA_QOS_EFILTERSTYLE = 0x00002B0B;
/// <summary>An invalid QOS filter type was used.</summary>
public const int WSA_QOS_EFILTERTYPE = 0x00002B0C;
/// <summary>An incorrect number of QOS FILTERSPECs were specified in the FLOWDESCRIPTOR.</summary>
public const int WSA_QOS_EFILTERCOUNT = 0x00002B0D;
/// <summary>An object with an invalid ObjectLength field was specified in the QOS provider-specific buffer.</summary>
public const int WSA_QOS_EOBJLENGTH = 0x00002B0E;
/// <summary>An incorrect number of flow descriptors was specified in the QOS structure.</summary>
public const int WSA_QOS_EFLOWCOUNT = 0x00002B0F;
/// <summary>An unrecognized object was found in the QOS provider-specific buffer.</summary>
public const int WSA_QOS_EUNKOWNPSOBJ = 0x00002B10;
/// <summary>An invalid policy object was found in the QOS provider-specific buffer.</summary>
public const int WSA_QOS_EPOLICYOBJ = 0x00002B11;
/// <summary>An invalid QOS flow descriptor was found in the flow descriptor list.</summary>
public const int WSA_QOS_EFLOWDESC = 0x00002B12;
/// <summary>An invalid or inconsistent flowspec was found in the QOS provider-specific buffer.</summary>
public const int WSA_QOS_EPSFLOWSPEC = 0x00002B13;
/// <summary>An invalid FILTERSPEC was found in the QOS provider-specific buffer.</summary>
public const int WSA_QOS_EPSFILTERSPEC = 0x00002B14;
/// <summary>An invalid shape discard mode object was found in the QOS provider-specific buffer.</summary>
public const int WSA_QOS_ESDMODEOBJ = 0x00002B15;
/// <summary>An invalid shaping rate object was found in the QOS provider-specific buffer.</summary>
public const int WSA_QOS_ESHAPERATEOBJ = 0x00002B16;
/// <summary>A reserved policy element was found in the QOS provider-specific buffer.</summary>
public const int WSA_QOS_RESERVED_PETYPE = 0x00002B17;
}
}

View File

@ -28,7 +28,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-__wsafdisset int __WSAFDIsSet( SOCKET , fd_set * );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock.h", MSDNShortId = "ca420136-0b3b-45a1-85ce-83ab6ba1a70a")]
public static extern SocketError __WSAFDIsSet(SOCKET arg1, in fd_set arg2);
public static extern WSRESULT __WSAFDIsSet(SOCKET arg1, in fd_set arg2);
/// <summary>
/// The <c>WSAAccept</c> function conditionally accepts a connection based on the return value of a condition function, provides
@ -403,7 +403,7 @@ namespace Vanara.PInvoke
// lpdwAddressStringLength );
[DllImport(Lib.Ws2_32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winsock2.h", MSDNShortId = "d72e55e6-79a9-4386-9e1a-24a322f13426")]
public static extern SocketError WSAAddressToString([In] SOCKADDR lpsaAddress, uint dwAddressLength, in WSAPROTOCOL_INFO lpProtocolInfo, StringBuilder lpszAddressString, ref uint lpdwAddressStringLength);
public static extern WSRESULT WSAAddressToString([In] SOCKADDR lpsaAddress, uint dwAddressLength, in WSAPROTOCOL_INFO lpProtocolInfo, StringBuilder lpszAddressString, ref uint lpdwAddressStringLength);
/// <summary>
/// <para>
@ -461,7 +461,7 @@ namespace Vanara.PInvoke
using var pc = lpProtocolInfo.HasValue ? new SafeCoTaskMemStruct<WSAPROTOCOL_INFO>(lpProtocolInfo.Value) : SafeCoTaskMemStruct<WSAPROTOCOL_INFO>.Null;
var sz = 1024U;
var err = WSAAddressToString(lpsaAddress, (uint)lpsaAddress.Size, pc, null, ref sz);
if (err == SocketError.Fault && sz > 0)
if (err == WSRESULT.WSAEFAULT && sz > 0)
{
StringBuilder sb = new((int)sz);
err = WSAAddressToString(lpsaAddress, (uint)lpsaAddress.Size, pc, sb, ref sz);
@ -574,7 +574,7 @@ namespace Vanara.PInvoke
// lpdwAddressStringLength );
[DllImport(Lib.Ws2_32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winsock2.h", MSDNShortId = "d72e55e6-79a9-4386-9e1a-24a322f13426")]
public static extern SocketError WSAAddressToString([In] SOCKADDR lpsaAddress, uint dwAddressLength, [Optional] IntPtr lpProtocolInfo, StringBuilder lpszAddressString, ref uint lpdwAddressStringLength);
public static extern WSRESULT WSAAddressToString([In] SOCKADDR lpsaAddress, uint dwAddressLength, [Optional] IntPtr lpProtocolInfo, StringBuilder lpszAddressString, ref uint lpdwAddressStringLength);
/// <summary>
/// <para>The <c>WSAAsyncGetHostByAddr</c> function asynchronously retrieves host information that corresponds to an address.</para>
@ -1861,7 +1861,7 @@ namespace Vanara.PInvoke
// u_int wMsg, long lEvent );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock.h", MSDNShortId = "a4d3f599-358c-4a94-91eb-7e1c80244250")]
public static extern SocketError WSAAsyncSelect(SOCKET s, HWND hWnd, uint wMsg, int lEvent);
public static extern WSRESULT WSAAsyncSelect(SOCKET s, HWND hWnd, uint wMsg, int lEvent);
/// <summary>The <c>WSACancelAsyncRequest</c> function cancels an incomplete asynchronous operation.</summary>
/// <param name="hAsyncTaskHandle">Handle that specifies the asynchronous operation to be canceled.</param>
@ -1921,7 +1921,7 @@ namespace Vanara.PInvoke
// hAsyncTaskHandle );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock.h", MSDNShortId = "0e53eccf-ef85-43ec-a02c-12896471a7a9")]
public static extern SocketError WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
public static extern WSRESULT WSACancelAsyncRequest(HANDLE hAsyncTaskHandle);
/// <summary>The <c>WSACleanup</c> function terminates use of the Winsock 2 DLL (Ws2_32.dll).</summary>
/// <returns>
@ -1999,7 +1999,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/desktop/api/winsock/nf-winsock-wsacleanup int WSACleanup( );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock.h", MSDNShortId = "72b7cc3e-be34-41e7-acbf-61742149ec8b")]
public static extern SocketError WSACleanup();
public static extern WSRESULT WSACleanup();
/// <summary>The <c>WSACloseEvent</c> function closes an open event object handle.</summary>
/// <param name="hEvent">Object handle identifying the open event.</param>
@ -2312,7 +2312,7 @@ namespace Vanara.PInvoke
// sockaddr *name, int namelen, LPWSABUF lpCallerData, LPWSABUF lpCalleeData, LPQOS lpSQOS, LPQOS lpGQOS );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "3b32cc6e-3df7-4104-a0d4-317fd445c7b2")]
public static extern SocketError WSAConnect(SOCKET s, [In] SOCKADDR name, int namelen, [In, Optional] IntPtr lpCallerData,
public static extern WSRESULT WSAConnect(SOCKET s, [In] SOCKADDR name, int namelen, [In, Optional] IntPtr lpCallerData,
[Out, Optional] IntPtr lpCalleeData, [Optional] IntPtr lpSQOS, [Optional] IntPtr lpGQOS);
/// <summary>
@ -2852,7 +2852,7 @@ namespace Vanara.PInvoke
// SOCKET s, DWORD dwProcessId, LPWSAPROTOCOL_INFOA lpProtocolInfo );
[DllImport(Lib.Ws2_32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winsock2.h", MSDNShortId = "d4028461-bfa6-4074-9460-5d1371790d41")]
public static extern SocketError WSADuplicateSocket(SOCKET s, uint dwProcessId, out WSAPROTOCOL_INFO lpProtocolInfo);
public static extern WSRESULT WSADuplicateSocket(SOCKET s, uint dwProcessId, out WSAPROTOCOL_INFO lpProtocolInfo);
/// <summary>The <c>WSAEnumNameSpaceProviders</c> function retrieves information on available namespace providers.</summary>
/// <param name="lpdwBufferLength">
@ -2930,7 +2930,7 @@ namespace Vanara.PInvoke
// WSAEnumNameSpaceProvidersW( LPDWORD lpdwBufferLength, LPWSANAMESPACE_INFOW lpnspBuffer );
[DllImport(Lib.Ws2_32, SetLastError = false, CharSet = CharSet.Unicode)]
[PInvokeData("winsock2.h", MSDNShortId = "f5b6cd42-c5cb-43b6-bb96-fd260217e252")]
public static extern SocketError WSAEnumNameSpaceProviders(ref uint lpdwBufferLength, [Out] IntPtr lpnspBuffer);
public static extern WSRESULT WSAEnumNameSpaceProviders(ref uint lpdwBufferLength, [Out] IntPtr lpnspBuffer);
/// <summary>The <c>WSAEnumNameSpaceProvidersEx</c> function retrieves information on available namespace providers.</summary>
/// <param name="lpdwBufferLength">
@ -3004,7 +3004,7 @@ namespace Vanara.PInvoke
// WSAEnumNameSpaceProvidersExA( LPDWORD lpdwBufferLength, LPWSANAMESPACE_INFOEXA lpnspBuffer );
[DllImport(Lib.Ws2_32, SetLastError = false, CharSet = CharSet.Unicode)]
[PInvokeData("winsock2.h", MSDNShortId = "34bc96aa-63f7-4ab8-9376-6f4b979225ca")]
public static extern SocketError WSAEnumNameSpaceProvidersEx(ref uint lpdwBufferLength, [Out] IntPtr lpnspBuffer);
public static extern WSRESULT WSAEnumNameSpaceProvidersEx(ref uint lpdwBufferLength, [Out] IntPtr lpnspBuffer);
/// <summary>
/// The <c>WSAEnumNetworkEvents</c> function discovers occurrences of network events for the indicated socket, clear internal
@ -3170,7 +3170,7 @@ namespace Vanara.PInvoke
// SOCKET s, WSAEVENT hEventObject, LPWSANETWORKEVENTS lpNetworkEvents );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "2e6abccd-c82c-4a6b-8720-259986ac9984")]
public static extern SocketError WSAEnumNetworkEvents(SOCKET s, [Optional] WSAEVENT hEventObject, out WSANETWORKEVENTS lpNetworkEvents);
public static extern WSRESULT WSAEnumNetworkEvents(SOCKET s, [Optional] WSAEVENT hEventObject, out WSANETWORKEVENTS lpNetworkEvents);
/// <summary>The <c>WSAEnumProtocols</c> function retrieves information about available transport protocols.</summary>
/// <param name="lpiProtocols">
@ -3278,7 +3278,7 @@ namespace Vanara.PInvoke
// lpiProtocols, LPWSAPROTOCOL_INFOA lpProtocolBuffer, LPDWORD lpdwBufferLength );
[DllImport(Lib.Ws2_32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winsock2.h", MSDNShortId = "928b6937-41a3-4268-a3bc-14c9e04870e4")]
public static extern SocketError WSAEnumProtocols([Optional, MarshalAs(UnmanagedType.LPArray)] int[] lpiProtocols, [Out] IntPtr lpProtocolBuffer, ref uint lpdwBufferLength);
public static extern WSRESULT WSAEnumProtocols([Optional, MarshalAs(UnmanagedType.LPArray)] int[] lpiProtocols, [Out] IntPtr lpProtocolBuffer, ref uint lpdwBufferLength);
/// <summary>
/// The <c>WSAEventSelect</c> function specifies an event object to be associated with the specified set of FD_XXX network events.
@ -3624,7 +3624,7 @@ namespace Vanara.PInvoke
// WSAEVENT hEventObject, long lNetworkEvents );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "f98a71e4-47fb-47a4-b37e-e4cc801a8f98")]
public static extern SocketError WSAEventSelect(SOCKET s, WSAEVENT hEventObject, FD lNetworkEvents);
public static extern WSRESULT WSAEventSelect(SOCKET s, WSAEVENT hEventObject, FD lNetworkEvents);
/// <summary>The <c>WSAGetLastError</c> function returns the error status for the last Windows Sockets operation that failed.</summary>
/// <returns>The return value indicates the error code for this thread's last Windows Sockets operation that failed.</returns>
@ -3671,7 +3671,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/desktop/api/winsock/nf-winsock-wsagetlasterror int WSAGetLastError( );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock.h", MSDNShortId = "39e41b66-44ed-46dc-bfc2-65228b669992")]
public static extern SocketError WSAGetLastError();
public static extern WSRESULT WSAGetLastError();
/// <summary>The <c>WSAGetOverlappedResult</c> function retrieves the results of an overlapped operation on the specified socket.</summary>
/// <param name="s">
@ -3935,7 +3935,7 @@ namespace Vanara.PInvoke
// lpServiceClassInfo );
[DllImport(Lib.Ws2_32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winsock2.h", MSDNShortId = "e177bb7d-c7d3-43a4-a809-ab8212feea2e")]
public static extern SocketError WSAGetServiceClassInfo(in Guid lpProviderId, in Guid lpServiceClassId, ref uint lpdwBufSize, IntPtr lpServiceClassInfo);
public static extern WSRESULT WSAGetServiceClassInfo(in Guid lpProviderId, in Guid lpServiceClassId, ref uint lpdwBufSize, IntPtr lpServiceClassInfo);
/// <summary>
/// The <c>WSAGetServiceClassNameByClassId</c> function retrieves the name of the service associated with the specified type. This
@ -4000,7 +4000,7 @@ namespace Vanara.PInvoke
// WSAGetServiceClassNameByClassIdA( LPGUID lpServiceClassId, LPSTR lpszServiceClassName, LPDWORD lpdwBufferLength );
[DllImport(Lib.Ws2_32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winsock2.h", MSDNShortId = "0a61751e-10e5-4f91-a0b2-8c1baf477653")]
public static extern SocketError WSAGetServiceClassNameByClassId(in Guid lpServiceClassId, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpszServiceClassName, ref uint lpdwBufferLength);
public static extern WSRESULT WSAGetServiceClassNameByClassId(in Guid lpServiceClassId, [MarshalAs(UnmanagedType.LPTStr)] StringBuilder lpszServiceClassName, ref uint lpdwBufferLength);
/// <summary>The <c>WSAHtonl</c> function converts a <c>u_long</c> from host byte order to network byte order.</summary>
/// <param name="s">A descriptor identifying a socket.</param>
@ -4062,7 +4062,7 @@ namespace Vanara.PInvoke
// hostlong, OUT u_long *lpnetlong );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "33512f49-d576-4439-ad8d-5c87387d6214")]
public static extern SocketError WSAHtonl([In] SOCKET s, [In] uint hostlong, out uint lpnetlong);
public static extern WSRESULT WSAHtonl([In] SOCKET s, [In] uint hostlong, out uint lpnetlong);
/// <summary>The <c>WSAHtons</c> function converts a <c>u_short</c> from host byte order to network byte order.</summary>
/// <param name="s">A descriptor identifying a socket.</param>
@ -4123,7 +4123,7 @@ namespace Vanara.PInvoke
// hostshort, OUT u_short *lpnetshort );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "95fb103b-f7dd-4fa4-bf68-ed8e87cdd96b")]
public static extern SocketError WSAHtons([In] SOCKET s, [In] ushort hostshort, out ushort lpnetshort);
public static extern WSRESULT WSAHtons([In] SOCKET s, [In] ushort hostshort, out ushort lpnetshort);
/// <summary>
/// The <c>WSAInstallServiceClass</c> function registers a service class schema within a namespace. This schema includes the class
@ -4190,7 +4190,7 @@ namespace Vanara.PInvoke
// WSAInstallServiceClassA( LPWSASERVICECLASSINFOA lpServiceClassInfo );
[DllImport(Lib.Ws2_32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winsock2.h", MSDNShortId = "06760319-aeeb-4ad7-b77a-01efea7ed904")]
public static extern SocketError WSAInstallServiceClass(in WSASERVICECLASSINFO lpServiceClassInfo);
public static extern WSRESULT WSAInstallServiceClass(in WSASERVICECLASSINFO lpServiceClassInfo);
/// <summary>The <c>WSAIoctl</c> function controls the mode of a socket.</summary>
/// <param name="s">A descriptor identifying a socket.</param>
@ -4429,7 +4429,7 @@ namespace Vanara.PInvoke
// LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "038aeca6-d7b7-4f74-ac69-4536c2e5118b")]
public static extern SocketError WSAIoctl(SOCKET s, uint dwIoControlCode, [In] IntPtr lpvInBuffer, uint cbInBuffer, [Out] IntPtr lpvOutBuffer, uint cbOutBuffer, out uint lpcbBytesReturned, [Optional] IntPtr lpOverlapped, [Optional] IntPtr lpCompletionRoutine);
public static extern WSRESULT WSAIoctl(SOCKET s, uint dwIoControlCode, [In] IntPtr lpvInBuffer, uint cbInBuffer, [Out] IntPtr lpvOutBuffer, uint cbOutBuffer, out uint lpcbBytesReturned, [Optional] IntPtr lpOverlapped, [Optional] IntPtr lpCompletionRoutine);
/// <summary>The <c>WSAIoctl</c> function controls the mode of a socket.</summary>
/// <param name="s">A descriptor identifying a socket.</param>
@ -4602,17 +4602,17 @@ namespace Vanara.PInvoke
// dwIoControlCode, LPVOID lpvInBuffer, DWORD cbInBuffer, LPVOID lpvOutBuffer, DWORD cbOutBuffer, LPDWORD lpcbBytesReturned,
// LPWSAOVERLAPPED lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine );
[PInvokeData("winsock2.h", MSDNShortId = "038aeca6-d7b7-4f74-ac69-4536c2e5118b")]
public static SocketError WSAIoctl<TIn, TOut>(SOCKET s, uint dwIoControlCode, TIn inVal, out TOut outVal) where TIn : struct where TOut : struct
public static WSRESULT WSAIoctl<TIn, TOut>(SOCKET s, uint dwIoControlCode, TIn inVal, out TOut outVal) where TIn : struct where TOut : struct
{
using SafeHGlobalHandle ptrIn = SafeHGlobalHandle.CreateFromStructure(inVal), ptrOut = SafeHGlobalHandle.CreateFromStructure<TOut>();
var ret = WSAIoctl(s, dwIoControlCode, ptrIn, ptrIn.Size, ptrOut, ptrOut.Size, out var bRet);
if (ret == SocketError.SocketError)
if (ret.Failed)
{
outVal = default;
return WSAGetLastError();
}
outVal = ptrOut.ToStructure<TOut>();
return SocketError.Success;
return 0;
}
/// <summary>
@ -5128,7 +5128,7 @@ namespace Vanara.PInvoke
// LPWSAQUERYSETA lpqsRestrictions, DWORD dwControlFlags, LPHANDLE lphLookup );
[DllImport(Lib.Ws2_32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winsock2.h", MSDNShortId = "448309ef-b9dd-4960-8016-d26691df59ec")]
public static extern SocketError WSALookupServiceBegin(in WSAQUERYSET lpqsRestrictions, LUP dwControlFlags, out HANDLE lphLookup);
public static extern WSRESULT WSALookupServiceBegin(in WSAQUERYSET lpqsRestrictions, LUP dwControlFlags, out HANDLE lphLookup);
/// <summary>
/// <para>
@ -5177,7 +5177,7 @@ namespace Vanara.PInvoke
// HANDLE hLookup );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "f9d2ac54-a818-464d-918e-80ebb5b1b106")]
public static extern SocketError WSALookupServiceEnd(HANDLE hLookup);
public static extern WSRESULT WSALookupServiceEnd(HANDLE hLookup);
/// <summary>
/// <para>
@ -5463,7 +5463,7 @@ namespace Vanara.PInvoke
// HANDLE hLookup, DWORD dwControlFlags, LPDWORD lpdwBufferLength, LPWSAQUERYSETA lpqsResults );
[DllImport(Lib.Ws2_32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winsock2.h", MSDNShortId = "ab4f1830-b38d-4224-a6a9-6d4512245ad6")]
public static extern SocketError WSALookupServiceNext(HANDLE hLookup, LUP dwControlFlags, ref uint lpdwBufferLength, [Out] IntPtr lpqsResults);
public static extern WSRESULT WSALookupServiceNext(HANDLE hLookup, LUP dwControlFlags, ref uint lpdwBufferLength, [Out] IntPtr lpqsResults);
/// <summary>The Windows Sockets <c>WSANSPIoctl</c> function enables developers to make I/O control calls to a registered namespace.</summary>
/// <param name="hLookup">The lookup handle returned from a previous call to the WSALookupServiceBegin function.</param>
@ -5595,7 +5595,7 @@ namespace Vanara.PInvoke
// LPWSACOMPLETION lpCompletion );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "6ecaedf0-0038-46d3-9916-c9cb069c5e92")]
public static extern SocketError WSANSPIoctl(HANDLE hLookup, uint dwControlCode, [In, Optional] IntPtr lpvInBuffer, uint cbInBuffer, [Out, Optional] IntPtr lpvOutBuffer, uint cbOutBuffer, out uint lpcbBytesReturned, [In, Optional] IntPtr lpCompletion);
public static extern WSRESULT WSANSPIoctl(HANDLE hLookup, uint dwControlCode, [In, Optional] IntPtr lpvInBuffer, uint cbInBuffer, [Out, Optional] IntPtr lpvOutBuffer, uint cbOutBuffer, out uint lpcbBytesReturned, [In, Optional] IntPtr lpCompletion);
/// <summary>The <c>WSANtohl</c> function converts a <c>u_long</c> from network byte order to host byte order.</summary>
/// <param name="s">A descriptor identifying a socket.</param>
@ -5657,7 +5657,7 @@ namespace Vanara.PInvoke
// u_long *lphostlong );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "7e3b42eb-3b93-459f-828a-c19e277882c7")]
public static extern SocketError WSANtohl(SOCKET s, uint netlong, out uint lphostlong);
public static extern WSRESULT WSANtohl(SOCKET s, uint netlong, out uint lphostlong);
/// <summary>The <c>WSANtohs</c> function converts a <c>u_short</c> from network byte order to host byte order.</summary>
/// <param name="s">A descriptor identifying a socket.</param>
@ -5718,7 +5718,7 @@ namespace Vanara.PInvoke
// u_short *lphostshort );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "0a4bc3a9-9919-4dcb-8a37-af37e0243c8f")]
public static extern SocketError WSANtohs(SOCKET s, ushort netshort, out ushort lphostshort);
public static extern WSRESULT WSANtohs(SOCKET s, ushort netshort, out ushort lphostshort);
/// <summary>The <c>WSAPoll</c> function determines status of one or more sockets.</summary>
/// <param name="fdArray">
@ -5912,7 +5912,7 @@ namespace Vanara.PInvoke
// fds, INT timeout );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "3f6f872c-5cee-49f3-bf22-2e8a5d147987")]
public static extern SocketError WSAPoll([In, Out, MarshalAs(UnmanagedType.LPArray)] WSAPOLLFD[] fdArray, uint fds, int timeout);
public static extern WSRESULT WSAPoll([In, Out, MarshalAs(UnmanagedType.LPArray)] WSAPOLLFD[] fdArray, uint fds, int timeout);
/// <summary>The <c>WSAProviderConfigChange</c> function notifies the application when the provider configuration is changed.</summary>
/// <param name="lpNotificationHandle">
@ -5996,7 +5996,7 @@ namespace Vanara.PInvoke
// lpCompletionRoutine );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "abaf367a-8f99-478c-a58c-d57e9f9cd8a1")]
public static extern SocketError WSAProviderConfigChange(ref HANDLE lpNotificationHandle, [In, Out, Optional] IntPtr lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
public static extern WSRESULT WSAProviderConfigChange(ref HANDLE lpNotificationHandle, [In, Out, Optional] IntPtr lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
/// <summary>The <c>WSARecv</c> function receives data from a connected socket or a bound connectionless socket.</summary>
/// <param name="s">A descriptor identifying a connected socket.</param>
@ -6389,7 +6389,7 @@ namespace Vanara.PInvoke
// LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "bfe66e11-e9a7-4321-ad55-3141113e9a03")]
public static extern SocketError WSARecv(SOCKET s, [In] IntPtr lpBuffers, uint dwBufferCount, out uint lpNumberOfBytesRecvd, ref MsgFlags lpFlags, [In, Out, Optional] IntPtr lpOverlapped,
public static extern WSRESULT WSARecv(SOCKET s, [In] IntPtr lpBuffers, uint dwBufferCount, out uint lpNumberOfBytesRecvd, ref MsgFlags lpFlags, [In, Out, Optional] IntPtr lpOverlapped,
[In, Optional, MarshalAs(UnmanagedType.FunctionPtr)] LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
/// <summary>
@ -6484,7 +6484,7 @@ namespace Vanara.PInvoke
// LPWSABUF lpInboundDisconnectData );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "33e0fb8e-3ece-427f-b3ef-43a0f5cf0cc8")]
public static extern SocketError WSARecvDisconnect(SOCKET s, [In, Out, Optional] IntPtr lpInboundDisconnectData);
public static extern WSRESULT WSARecvDisconnect(SOCKET s, [In, Out, Optional] IntPtr lpInboundDisconnectData);
/// <summary>The <c>WSARecvFrom</c> function receives a datagram and stores the source address.</summary>
/// <param name="s">A descriptor identifying a socket.</param>
@ -6784,7 +6784,7 @@ namespace Vanara.PInvoke
// lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "8617dbb8-0e4e-4cd3-9597-5d20de6778f6")]
public static extern SocketError WSARecvFrom(SOCKET s, [In, Out, Optional, MarshalAs(UnmanagedType.LPArray)] WSABUF[] lpBuffers, uint dwBufferCount, out uint lpNumberOfBytesRecvd, ref MsgFlags lpFlags,
public static extern WSRESULT WSARecvFrom(SOCKET s, [In, Out, Optional, MarshalAs(UnmanagedType.LPArray)] WSABUF[] lpBuffers, uint dwBufferCount, out uint lpNumberOfBytesRecvd, ref MsgFlags lpFlags,
[Out] SOCKADDR lpFrom, ref int lpFromlen, [In, Out, Optional] IntPtr lpOverlapped, [In, Optional, MarshalAs(UnmanagedType.FunctionPtr)] LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
/// <summary>The <c>WSARemoveServiceClass</c> function permanently removes the service class schema from the registry.</summary>
@ -6831,7 +6831,7 @@ namespace Vanara.PInvoke
// LPGUID lpServiceClassId );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "7d72f727-cca9-4a07-beb4-d64f23c1f0c1")]
public static extern SocketError WSARemoveServiceClass(in Guid lpServiceClassId);
public static extern WSRESULT WSARemoveServiceClass(in Guid lpServiceClassId);
/// <summary>The <c>WSAResetEvent</c> function resets the state of the specified event object to nonsignaled.</summary>
/// <param name="hEvent">A handle that identifies an open event object handle.</param>
@ -7175,7 +7175,7 @@ namespace Vanara.PInvoke
// lpCompletionRoutine );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "764339e6-a1ac-455d-8ebd-ad0fa50dc3b0")]
public static extern SocketError WSASend(SOCKET s, [In, MarshalAs(UnmanagedType.LPArray)] WSABUF[] lpBuffers, uint dwBufferCount, out uint lpNumberOfBytesSent,
public static extern WSRESULT WSASend(SOCKET s, [In, MarshalAs(UnmanagedType.LPArray)] WSABUF[] lpBuffers, uint dwBufferCount, out uint lpNumberOfBytesSent,
MsgFlags dwFlags, [In, Out, Optional] IntPtr lpOverlapped, [In, Optional, MarshalAs(UnmanagedType.FunctionPtr)] LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
/// <summary>
@ -7259,7 +7259,7 @@ namespace Vanara.PInvoke
// LPWSABUF lpOutboundDisconnectData );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "c05fc719-e35a-4194-ac01-a294b19ccce9")]
public static extern SocketError WSASendDisconnect(SOCKET s, in WSABUF lpOutboundDisconnectData);
public static extern WSRESULT WSASendDisconnect(SOCKET s, in WSABUF lpOutboundDisconnectData);
/// <summary>
/// The <c>WSASendDisconnect</c> function initiates termination of the connection for the socket and sends disconnect data.
@ -7342,7 +7342,7 @@ namespace Vanara.PInvoke
// LPWSABUF lpOutboundDisconnectData );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "c05fc719-e35a-4194-ac01-a294b19ccce9")]
public static extern SocketError WSASendDisconnect(SOCKET s, [In, Optional] IntPtr lpOutboundDisconnectData);
public static extern WSRESULT WSASendDisconnect(SOCKET s, [In, Optional] IntPtr lpOutboundDisconnectData);
/// <summary>The <c>WSASendMsg</c> function sends data and optional control information from connected and unconnected sockets.</summary>
/// <param name="Handle">A descriptor identifying the socket.</param>
@ -7649,7 +7649,7 @@ namespace Vanara.PInvoke
// lpCompletionRoutine );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "3b2ba645-6a70-4ba2-b4a2-5bde0c7f8d08")]
public static extern SocketError WSASendMsg(SOCKET Handle, in WSAMSG lpMsg, MsgFlags dwFlags, out uint lpNumberOfBytesSent, [In, Out, Optional] IntPtr lpOverlapped,
public static extern WSRESULT WSASendMsg(SOCKET Handle, in WSAMSG lpMsg, MsgFlags dwFlags, out uint lpNumberOfBytesSent, [In, Out, Optional] IntPtr lpOverlapped,
[In, Optional, MarshalAs(UnmanagedType.FunctionPtr)] LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
/// <summary>The <c>WSASendTo</c> function sends data to a specific destination, using overlapped I/O where applicable.</summary>
@ -7955,7 +7955,7 @@ namespace Vanara.PInvoke
// lpOverlapped, LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "e3a11522-871c-4d6b-a2e6-ca91ffc2b698")]
public static extern SocketError WSASendTo(SOCKET s, [In, MarshalAs(UnmanagedType.LPArray)] WSABUF[] lpBuffers, uint dwBufferCount, out uint lpNumberOfBytesSent,
public static extern WSRESULT WSASendTo(SOCKET s, [In, MarshalAs(UnmanagedType.LPArray)] WSABUF[] lpBuffers, uint dwBufferCount, out uint lpNumberOfBytesSent,
MsgFlags dwFlags, [In, Optional] SOCKADDR lpTo, int iTolen, [In, Out, Optional] IntPtr lpOverlapped,
[In, Optional, MarshalAs(UnmanagedType.FunctionPtr)] LPWSAOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine);
@ -8035,7 +8035,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-wsasetlasterror void WSASetLastError( int iError );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("winsock.h", MSDNShortId = "596155ee-3dcc-4ae3-97ab-0653e019cbee")]
public static extern void WSASetLastError(SocketError iError);
public static extern void WSASetLastError(WSRESULT iError);
/// <summary>The <c>WSASetService</c> function registers or removes from the registry a service instance within one or more namespaces.</summary>
/// <param name="lpqsRegInfo">A pointer to the service information for registration or deregistration.</param>
@ -8312,7 +8312,7 @@ namespace Vanara.PInvoke
// lpqsRegInfo, WSAESETSERVICEOP essoperation, DWORD dwControlFlags );
[DllImport(Lib.Ws2_32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winsock2.h", MSDNShortId = "21a8ff26-4c9e-4846-a75a-1a27c746edab")]
public static extern SocketError WSASetService(in WSAQUERYSET lpqsRegInfo, WSAESETSERVICEOP essoperation, ServiceInstallFlags dwControlFlags);
public static extern WSRESULT WSASetService(in WSAQUERYSET lpqsRegInfo, WSAESETSERVICEOP essoperation, ServiceInstallFlags dwControlFlags);
/// <summary>The <c>WSASocket</c> function creates a socket that is bound to a specific transport-service provider.</summary>
/// <param name="af">
@ -9766,7 +9766,7 @@ namespace Vanara.PInvoke
// AddressString, INT AddressFamily, LPWSAPROTOCOL_INFOA lpProtocolInfo, LPSOCKADDR lpAddress, LPINT lpAddressLength );
[DllImport(Lib.Ws2_32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winsock2.h", MSDNShortId = "7b9946c3-c8b3-45ae-9bde-03faaf604bba")]
public static extern SocketError WSAStringToAddress([MarshalAs(UnmanagedType.LPTStr)] string AddressString, ADDRESS_FAMILY AddressFamily, in WSAPROTOCOL_INFO lpProtocolInfo, [Out] SOCKADDR lpAddress, ref int lpAddressLength);
public static extern WSRESULT WSAStringToAddress([MarshalAs(UnmanagedType.LPTStr)] string AddressString, ADDRESS_FAMILY AddressFamily, in WSAPROTOCOL_INFO lpProtocolInfo, [Out] SOCKADDR lpAddress, ref int lpAddressLength);
/// <summary>
/// The <c>WSAStringToAddress</c> function converts a network address in its standard text presentation form into its numeric binary
@ -9847,7 +9847,7 @@ namespace Vanara.PInvoke
// AddressString, INT AddressFamily, LPWSAPROTOCOL_INFOA lpProtocolInfo, LPSOCKADDR lpAddress, LPINT lpAddressLength );
[DllImport(Lib.Ws2_32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winsock2.h", MSDNShortId = "7b9946c3-c8b3-45ae-9bde-03faaf604bba")]
public static extern SocketError WSAStringToAddress([MarshalAs(UnmanagedType.LPTStr)] string AddressString, ADDRESS_FAMILY AddressFamily, [In, Optional] IntPtr lpProtocolInfo, [Out] SOCKADDR lpAddress, ref int lpAddressLength);
public static extern WSRESULT WSAStringToAddress([MarshalAs(UnmanagedType.LPTStr)] string AddressString, ADDRESS_FAMILY AddressFamily, [In, Optional] IntPtr lpProtocolInfo, [Out] SOCKADDR lpAddress, ref int lpAddressLength);
/// <summary>
/// The <c>WSAStringToAddress</c> function converts a network address in its standard text presentation form into its numeric binary
@ -9928,7 +9928,7 @@ namespace Vanara.PInvoke
// AddressString, INT AddressFamily, LPWSAPROTOCOL_INFOA lpProtocolInfo, LPSOCKADDR lpAddress, LPINT lpAddressLength );
[DllImport(Lib.Ws2_32, SetLastError = false, CharSet = CharSet.Auto)]
[PInvokeData("winsock2.h", MSDNShortId = "7b9946c3-c8b3-45ae-9bde-03faaf604bba")]
public static extern SocketError WSAStringToAddress([MarshalAs(UnmanagedType.LPTStr)] string AddressString, ADDRESS_FAMILY AddressFamily, [In, Optional] IntPtr lpProtocolInfo, [Out] IntPtr lpAddress, ref int lpAddressLength);
public static extern WSRESULT WSAStringToAddress([MarshalAs(UnmanagedType.LPTStr)] string AddressString, ADDRESS_FAMILY AddressFamily, [In, Optional] IntPtr lpProtocolInfo, [Out] IntPtr lpAddress, ref int lpAddressLength);
/// <summary>
/// The <c>WSAStringToAddress</c> function converts a network address in its standard text presentation form into its numeric binary

View File

@ -517,7 +517,7 @@ namespace Vanara.PInvoke
// namelen );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winsock.h", MSDNShortId = "3a651daa-7404-4ef7-8cff-0d3dff41a8e8")]
public static extern SocketError bind(SOCKET s, [In] SOCKADDR addr, int namelen);
public static extern WSRESULT bind(SOCKET s, [In] SOCKADDR addr, int namelen);
/// <summary>The <c>closesocket</c> function closes an existing socket.</summary>
/// <param name="s">A descriptor identifying the socket to close.</param>
@ -787,7 +787,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/desktop/api/winsock/nf-winsock-closesocket int closesocket( IN SOCKET s );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winsock.h", MSDNShortId = "2f357aa8-389b-4c92-8a9f-289e048cc41c")]
public static extern SocketError closesocket([In] SOCKET s);
public static extern WSRESULT closesocket([In] SOCKET s);
/// <summary>The <c>connect</c> function establishes a connection to a specified socket.</summary>
/// <param name="s">A descriptor identifying an unconnected socket.</param>
@ -1018,7 +1018,7 @@ namespace Vanara.PInvoke
// *name, int namelen );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "13468139-dc03-45bd-850c-7ac2dbcb6e60")]
public static extern SocketError connect(SOCKET s, SOCKADDR name, int namelen);
public static extern WSRESULT connect(SOCKET s, SOCKADDR name, int namelen);
/// <summary>The <c>gethostname</c> function retrieves the standard host name for the local computer.</summary>
/// <param name="name">A pointer to a buffer that receives the local host name.</param>
@ -1090,7 +1090,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-gethostname int gethostname( char *name, int namelen );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Ansi)]
[PInvokeData("winsock.h", MSDNShortId = "8fa40b60-0e93-493b-aee1-cea6cf595707")]
public static extern SocketError gethostname(StringBuilder name, int namelen);
public static extern WSRESULT gethostname(StringBuilder name, int namelen);
/// <summary>The <c>GetHostNameW</c> function retrieves the standard host name for the local computer as a Unicode string.</summary>
/// <param name="name">A pointer to a buffer that receives the local host name as a <c>null</c>-terminated Unicode string.</param>
@ -1166,7 +1166,7 @@ namespace Vanara.PInvoke
// namelen );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("winsock2.h", MSDNShortId = "787EB209-5944-4F0A-8550-FE1115C2298A")]
public static extern SocketError GetHostNameW(StringBuilder name, int namelen);
public static extern WSRESULT GetHostNameW(StringBuilder name, int namelen);
/// <summary>The <c>getpeername</c> function retrieves the address of the peer to which a socket is connected.</summary>
/// <param name="s">A descriptor identifying a connected socket.</param>
@ -1232,7 +1232,7 @@ namespace Vanara.PInvoke
// *namelen );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winsock.h", MSDNShortId = "df2679a5-cdd9-468b-823a-f98044189f65")]
public static extern SocketError getpeername(SOCKET s, SOCKADDR name, ref int namelen);
public static extern WSRESULT getpeername(SOCKET s, SOCKADDR name, ref int namelen);
/// <summary>The <c>getprotobyname</c> function retrieves the protocol information corresponding to a protocol name.</summary>
/// <param name="name">Pointer to a null-terminated protocol name.</param>
@ -1722,7 +1722,7 @@ namespace Vanara.PInvoke
// int *namelen );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winsock.h", MSDNShortId = "be20a731-cdfc-48ae-90b2-43f2cf9ecf6d")]
public static extern SocketError getsockname(SOCKET s, SOCKADDR name, ref int namelen);
public static extern WSRESULT getsockname(SOCKET s, SOCKADDR name, ref int namelen);
/// <summary>The <c>getsockopt</c> function retrieves a socket option.</summary>
/// <param name="s">A descriptor identifying a socket.</param>
@ -2157,7 +2157,7 @@ namespace Vanara.PInvoke
// optname, char *optval, int *optlen );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Ansi)]
[PInvokeData("winsock.h", MSDNShortId = "25bc511d-7a9f-41c1-8983-1af1e3f8bf2d")]
public static extern SocketError getsockopt(SOCKET s, int level, int optname, [Optional] IntPtr optval, ref int optlen);
public static extern WSRESULT getsockopt(SOCKET s, int level, int optname, [Optional] IntPtr optval, ref int optlen);
/// <summary>The <c>htonl</c> function converts a <c>u_long</c> from host to TCP/IP network byte order (which is big-endian).</summary>
/// <param name="hostlong">A 32-bit number in host byte order.</param>
@ -2421,7 +2421,7 @@ namespace Vanara.PInvoke
// *argp );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winsock.h", MSDNShortId = "048fcb8d-acd3-4917-a997-dd133db399f8")]
public static extern SocketError ioctlsocket(SOCKET s, int cmd, IntPtr argp);
public static extern WSRESULT ioctlsocket(SOCKET s, int cmd, IntPtr argp);
/// <summary>The <c>listen</c> function places a socket in a state in which it is listening for an incoming connection.</summary>
/// <param name="s">A descriptor identifying a bound, unconnected socket.</param>
@ -2555,7 +2555,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/desktop/api/winsock2/nf-winsock2-listen int WSAAPI listen( SOCKET s, int backlog );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "1233feeb-a8c1-49ac-ab34-82af224ecf00")]
public static extern SocketError listen(SOCKET s, int backlog);
public static extern WSRESULT listen(SOCKET s, int backlog);
/// <summary>
/// The <c>ntohl</c> function converts a <c>u_long</c> from TCP/IP network order to host byte order (which is little-endian on Intel processors).
@ -2818,7 +2818,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-recv int recv( SOCKET s, char *buf, int len, int flags );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winsock.h", MSDNShortId = "8c247cd3-479f-45d0-a038-a24e80cc7c73")]
public static extern SocketError recv(SOCKET s, IntPtr buf, int len, MsgFlags flags);
public static extern WSRESULT recv(SOCKET s, IntPtr buf, int len, MsgFlags flags);
/// <summary>The <c>recvfrom</c> function receives a datagram and stores the source address.</summary>
/// <param name="s">A descriptor identifying a bound socket.</param>
@ -3001,7 +3001,7 @@ namespace Vanara.PInvoke
// flags, sockaddr *from, int *fromlen );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winsock.h", MSDNShortId = "3e4282e0-3ed0-43e7-9b27-72ec36b9cfa1")]
public static extern SocketError recvfrom(SOCKET s, IntPtr buf, int len, int flags, SOCKADDR from, ref int fromlen);
public static extern WSRESULT recvfrom(SOCKET s, IntPtr buf, int len, int flags, SOCKADDR from, ref int fromlen);
/// <summary>
/// The <c>select</c> function determines the status of one or more sockets, waiting if necessary, to perform synchronous I/O.
@ -3182,7 +3182,7 @@ namespace Vanara.PInvoke
// fd_set *writefds, fd_set *exceptfds, const timeval *timeout );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "NF:winsock2.select")]
public static extern SocketError select([Optional] int nfds, ref fd_set readfds, ref fd_set writefds, ref fd_set exceptfds, in TIMEVAL timeout);
public static extern WSRESULT select([Optional] int nfds, ref fd_set readfds, ref fd_set writefds, ref fd_set exceptfds, in TIMEVAL timeout);
/// <summary>
/// The <c>select</c> function determines the status of one or more sockets, waiting if necessary, to perform synchronous I/O.
@ -3363,7 +3363,7 @@ namespace Vanara.PInvoke
// fd_set *writefds, fd_set *exceptfds, const timeval *timeout );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "NF:winsock2.select")]
public static extern SocketError select([Optional] int nfds, [In, Out, Optional] IntPtr readfds, [In, Out, Optional] IntPtr writefds, [In, Out, Optional] IntPtr exceptfds, [In, Optional] IntPtr timeout);
public static extern WSRESULT select([Optional] int nfds, [In, Out, Optional] IntPtr readfds, [In, Out, Optional] IntPtr writefds, [In, Out, Optional] IntPtr exceptfds, [In, Optional] IntPtr timeout);
/// <summary>The <c>send</c> function sends data on a connected socket.</summary>
/// <param name="s">A descriptor identifying a connected socket.</param>
@ -3559,7 +3559,7 @@ namespace Vanara.PInvoke
// int flags );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winsock2.h", MSDNShortId = "902bb9cf-d847-43fc-8282-394d619b8f1b")]
public static extern SocketError send(SOCKET s, IntPtr buf, int len, int flags);
public static extern WSRESULT send(SOCKET s, IntPtr buf, int len, int flags);
/// <summary>The <c>sendto</c> function sends data to a specific destination.</summary>
/// <param name="s">A descriptor identifying a (possibly connected) socket.</param>
@ -3792,7 +3792,7 @@ namespace Vanara.PInvoke
// flags, const sockaddr *to, int tolen );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winsock.h", MSDNShortId = "a1c89c6b-d11d-4d3e-a664-af2beed0cd09")]
public static extern SocketError sendto(SOCKET s, IntPtr buf, int len, int flags, SOCKADDR to, int tolen);
public static extern WSRESULT sendto(SOCKET s, IntPtr buf, int len, int flags, SOCKADDR to, int tolen);
/// <summary>The <c>setsockopt</c> function sets a socket option.</summary>
/// <param name="s">A descriptor that identifies a socket.</param>
@ -4146,7 +4146,7 @@ namespace Vanara.PInvoke
// optname, const char *optval, int optlen );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winsock.h", MSDNShortId = "3a6960c9-0c04-4403-aee1-ce250459dc30")]
public static extern SocketError setsockopt(SOCKET s, int level, int optname, IntPtr optval, int optlen);
public static extern WSRESULT setsockopt(SOCKET s, int level, int optname, IntPtr optval, int optlen);
/// <summary>The <c>setsockopt</c> function sets a socket option.</summary>
/// <param name="s">A descriptor that identifies a socket.</param>
@ -4498,7 +4498,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-setsockopt int setsockopt( SOCKET s, int level, int
// optname, const char *optval, int optlen );
[PInvokeData("winsock.h", MSDNShortId = "3a6960c9-0c04-4403-aee1-ce250459dc30")]
public static SocketError setsockopt<TLvl, TIn>(SOCKET s, TLvl level, int optname, in TIn optval) where TIn : struct where TLvl : IConvertible
public static WSRESULT setsockopt<TLvl, TIn>(SOCKET s, TLvl level, int optname, in TIn optval) where TIn : struct where TLvl : IConvertible
{
using var mem = SafeCoTaskMemHandle.CreateFromStructure(optval);
return setsockopt(s, level.ToInt32(null), optname, mem, mem.Size);
@ -4686,7 +4686,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/winsock/nf-winsock-shutdown int shutdown( SOCKET s, int how );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("winsock.h", MSDNShortId = "6998f0c6-adc9-481f-b9fb-75f9c9f5caaf")]
public static extern SocketError shutdown(SOCKET s, SD how);
public static extern WSRESULT shutdown(SOCKET s, SD how);
/// <summary>The <c>socket</c> function creates a socket that is bound to a specific transport service provider.</summary>
/// <param name="af">

View File

@ -84,7 +84,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/ws2spi/nc-ws2spi-lpnspv2cleanup LPNSPV2CLEANUP Lpnspv2cleanup; INT
// Lpnspv2cleanup( LPGUID lpProviderId, LPVOID pvClientSessionArg ) {...}
[PInvokeData("ws2spi.h", MSDNShortId = "36064c0e-c83c-4819-a3e4-c89df50eb659")]
public delegate SocketError LPNSPV2CLEANUP(in Guid lpProviderId, IntPtr pvClientSessionArg);
public delegate WSRESULT LPNSPV2CLEANUP(in Guid lpProviderId, IntPtr pvClientSessionArg);
/// <summary>
/// The <c>NSPv2ClientSessionRundown</c> function notifies a namespace service provider version-2 (NSPv2) provider that the client
@ -445,7 +445,7 @@ namespace Vanara.PInvoke
// dwControlFlags, LPVOID lpvClientSessionArg, LPHANDLE lphLookup ) {...}
[PInvokeData("ws2spi.h", MSDNShortId = "5664b85d-8432-4068-aa97-caa57d9377ac")]
[UnmanagedFunctionPointer(CallingConvention.Winapi, CharSet = CharSet.Unicode)]
public delegate SocketError LPNSPV2LOOKUPSERVICEBEGIN(in Guid lpProviderId, in WSAQUERYSET2W lpqsRestrictions, uint dwControlFlags, IntPtr lpvClientSessionArg, out HANDLE lphLookup);
public delegate WSRESULT LPNSPV2LOOKUPSERVICEBEGIN(in Guid lpProviderId, in WSAQUERYSET2W lpqsRestrictions, uint dwControlFlags, IntPtr lpvClientSessionArg, out HANDLE lphLookup);
/// <summary>
/// The <c>NSPv2LookupServiceEnd</c> function is called to free the handle after previous calls to NSPv2LookupServiceBegin and NSPv2LookupServiceNextEx.
@ -494,7 +494,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/ws2spi/nc-ws2spi-lpnspv2lookupserviceend LPNSPV2LOOKUPSERVICEEND
// Lpnspv2lookupserviceend; INT Lpnspv2lookupserviceend( HANDLE hLookup ) {...}
[PInvokeData("ws2spi.h", MSDNShortId = "5f2b56c5-3a8e-4bf9-8f28-d2a06543227b")]
public delegate SocketError LPNSPV2LOOKUPSERVICEEND(HANDLE hLookup);
public delegate WSRESULT LPNSPV2LOOKUPSERVICEEND(HANDLE hLookup);
/// <summary>
/// The <c>NSPv2LookupServiceNextEx</c> function is called after obtaining a handle from a previous call to NSPv2LookupServiceBegin
@ -1046,7 +1046,7 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/ws2spi/nc-ws2spi-lpnspv2startup LPNSPV2STARTUP Lpnspv2startup; INT
// Lpnspv2startup( LPGUID lpProviderId, LPVOID *ppvClientSessionArg ) {...}
[PInvokeData("ws2spi.h", MSDNShortId = "93224e66-9c94-4b5c-af11-ae988b74bc03")]
public delegate SocketError LPNSPV2STARTUP(in Guid lpProviderId, out IntPtr ppvClientSessionArg);
public delegate WSRESULT LPNSPV2STARTUP(in Guid lpProviderId, out IntPtr ppvClientSessionArg);
/// <summary>The WSC_PROVIDER_AUDIT_INFO structure is not currently used.</summary>
/// <remarks>The WSC_PROVIDER_AUDIT_INFO structure is not currently used.</remarks>
@ -1170,7 +1170,7 @@ namespace Vanara.PInvoke
// WPUCompleteOverlappedRequest( SOCKET s, LPWSAOVERLAPPED lpOverlapped, DWORD dwError, DWORD cbTransferred, LPINT lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "b0e5015f-d23f-46da-91b1-f646111f70f9")]
public static extern SocketError WPUCompleteOverlappedRequest(SOCKET s, ref WSAOVERLAPPED lpOverlapped, uint dwError, uint cbTransferred, out int lpErrno);
public static extern WSRESULT WPUCompleteOverlappedRequest(SOCKET s, ref WSAOVERLAPPED lpOverlapped, uint dwError, uint cbTransferred, out int lpErrno);
/// <summary>
/// The <c>WSAAdvertiseProvider</c> function makes a specific namespace version-2 provider available for all eligible clients.
@ -1262,7 +1262,7 @@ namespace Vanara.PInvoke
// GUID *puuidProviderId, const LPCNSPV2_ROUTINE pNSPv2Routine );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "574ebfa4-d7f2-43c2-b1ec-35ce3db9151f")]
public static extern SocketError WSAAdvertiseProvider(in Guid puuidProviderId, in NSPV2_ROUTINE pNSPv2Routine);
public static extern WSRESULT WSAAdvertiseProvider(in Guid puuidProviderId, in NSPV2_ROUTINE pNSPv2Routine);
/// <summary>
/// The <c>WSAProviderCompleteAsyncCall</c> function notifies a client when an asynchronous call to a namespace version-2 provider
@ -1326,7 +1326,7 @@ namespace Vanara.PInvoke
// WSAProviderCompleteAsyncCall( HANDLE hAsyncCall, INT iRetCode );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "2bbc20ae-ad6d-47f6-8ca9-dd5559236fbe")]
public static extern SocketError WSAProviderCompleteAsyncCall(HANDLE hAsyncCall, int iRetCode);
public static extern WSRESULT WSAProviderCompleteAsyncCall(HANDLE hAsyncCall, int iRetCode);
/// <summary>
/// The <c>WSAUnadvertiseProvider</c> function makes a specific namespace version-2 provider no longer available for clients.
@ -1368,7 +1368,7 @@ namespace Vanara.PInvoke
// const GUID *puuidProviderId );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "5975b496-53a7-4f8a-8efc-27ef447596c2")]
public static extern SocketError WSAUnadvertiseProvider(in Guid puuidProviderId);
public static extern WSRESULT WSAUnadvertiseProvider(in Guid puuidProviderId);
/// <summary>
/// The <c>WSCDeinstallProvider</c> function removes the specified transport provider from the system configuration database.
@ -1442,7 +1442,7 @@ namespace Vanara.PInvoke
// lpProviderId, LPINT lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "9a2afd11-1944-491f-9c92-9dbac6b3b28e")]
public static extern SocketError WSCDeinstallProvider(in Guid lpProviderId, out int lpErrno);
public static extern WSRESULT WSCDeinstallProvider(in Guid lpProviderId, out int lpErrno);
/// <summary>
/// The <c>WSCDeinstallProvider32</c> function removes the specified 32-bit transport provider from the system configuration database.
@ -1522,7 +1522,7 @@ namespace Vanara.PInvoke
// lpProviderId, LPINT lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "3de74059-dbfb-49b9-830b-7b2f81f8b68c")]
public static extern SocketError WSCDeinstallProvider32(in Guid lpProviderId, out int lpErrno);
public static extern WSRESULT WSCDeinstallProvider32(in Guid lpProviderId, out int lpErrno);
/// <summary>
/// The <c>WSCEnableNSProvider</c> function changes the state of a given namespace provider. It is intended to give the end-user the
@ -1591,7 +1591,7 @@ namespace Vanara.PInvoke
// lpProviderId, BOOL fEnable );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "2dff5af6-3011-4e3f-b812-fffaca8fa2d9")]
public static extern SocketError WSCEnableNSProvider(in Guid lpProviderId, [MarshalAs(UnmanagedType.Bool)] bool fEnable);
public static extern WSRESULT WSCEnableNSProvider(in Guid lpProviderId, [MarshalAs(UnmanagedType.Bool)] bool fEnable);
/// <summary>
/// The <c>WSCEnableNSProvider32</c> function enables or disables a specified 32-bit namespace provider. It is intended to give the
@ -1666,7 +1666,7 @@ namespace Vanara.PInvoke
// lpProviderId, BOOL fEnable );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "5ab4f8bd-d32d-4962-aac7-2d92847d0e03")]
public static extern SocketError WSCEnableNSProvider32(in Guid lpProviderId, [MarshalAs(UnmanagedType.Bool)] bool fEnable);
public static extern WSRESULT WSCEnableNSProvider32(in Guid lpProviderId, [MarshalAs(UnmanagedType.Bool)] bool fEnable);
/// <summary>The <c>WSCEnumNameSpaceProviders32</c> function returns information on available 32-bit namespace providers.</summary>
/// <param name="lpdwBufferLength">
@ -1726,7 +1726,7 @@ namespace Vanara.PInvoke
// WSCEnumNameSpaceProviders32( LPDWORD lpdwBufferLength, LPWSANAMESPACE_INFOW lpnspBuffer );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("ws2spi.h", MSDNShortId = "792737d9-231d-4524-b1a6-b9904951d5b4")]
public static extern SocketError WSCEnumNameSpaceProviders32(ref uint lpdwBufferLength, [In, Out] IntPtr lpnspBuffer);
public static extern WSRESULT WSCEnumNameSpaceProviders32(ref uint lpdwBufferLength, [In, Out] IntPtr lpnspBuffer);
/// <summary>The <c>WSCEnumNameSpaceProvidersEx32</c> function retrieves information on available 32-bit namespace providers.</summary>
/// <param name="lpdwBufferLength">
@ -1795,7 +1795,7 @@ namespace Vanara.PInvoke
// WSCEnumNameSpaceProvidersEx32( LPDWORD lpdwBufferLength, LPWSANAMESPACE_INFOEXW lpnspBuffer );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("ws2spi.h", MSDNShortId = "544120b2-7575-4deb-8429-2bd4582eceef")]
public static extern SocketError WSCEnumNameSpaceProvidersEx32(ref uint lpdwBufferLength, [In, Out] IntPtr lpnspBuffer);
public static extern WSRESULT WSCEnumNameSpaceProvidersEx32(ref uint lpdwBufferLength, [In, Out] IntPtr lpnspBuffer);
/// <summary>The <c>WSCEnumProtocols</c> function retrieves information about available transport protocols.</summary>
/// <param name="lpiProtocols">
@ -1876,7 +1876,7 @@ namespace Vanara.PInvoke
// LPWSAPROTOCOL_INFOW lpProtocolBuffer, LPDWORD lpdwBufferLength, LPINT lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("ws2spi.h", MSDNShortId = "c2e5332f-3327-4624-96b4-8e321795961d")]
public static extern SocketError WSCEnumProtocols([Optional, MarshalAs(UnmanagedType.LPArray)] int[] lpiProtocols, IntPtr lpProtocolBuffer, ref uint lpdwBufferLength, out int lpErrno);
public static extern WSRESULT WSCEnumProtocols([Optional, MarshalAs(UnmanagedType.LPArray)] int[] lpiProtocols, IntPtr lpProtocolBuffer, ref uint lpdwBufferLength, out int lpErrno);
/// <summary>The <c>WSCEnumProtocols32</c> function retrieves information about available transport protocols.</summary>
/// <param name="lpiProtocols">
@ -1963,7 +1963,7 @@ namespace Vanara.PInvoke
// lpiProtocols, LPWSAPROTOCOL_INFOW lpProtocolBuffer, LPDWORD lpdwBufferLength, LPINT lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "f46042f6-0b14-4a14-abc1-4e40c34b1599")]
public static extern SocketError WSCEnumProtocols32([Optional, MarshalAs(UnmanagedType.LPArray)] int[] lpiProtocols, IntPtr lpProtocolBuffer, ref uint lpdwBufferLength, out int lpErrno);
public static extern WSRESULT WSCEnumProtocols32([Optional, MarshalAs(UnmanagedType.LPArray)] int[] lpiProtocols, IntPtr lpProtocolBuffer, ref uint lpdwBufferLength, out int lpErrno);
/// <summary>
/// <para>
@ -2152,7 +2152,7 @@ namespace Vanara.PInvoke
// LPCWSTR Path, DWORD PathLength, LPCWSTR Extra, DWORD ExtraLength, DWORD *pPermittedLspCategories, LPINT lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "c4e149ce-dff9-401a-8488-23676992c04d")]
public static extern SocketError WSCGetApplicationCategory([MarshalAs(UnmanagedType.LPWStr)] string Path, uint PathLength, [MarshalAs(UnmanagedType.LPWStr)] string Extra, uint ExtraLength, out uint pPermittedLspCategories, out int lpErrno);
public static extern WSRESULT WSCGetApplicationCategory([MarshalAs(UnmanagedType.LPWStr)] string Path, uint PathLength, [MarshalAs(UnmanagedType.LPWStr)] string Extra, uint ExtraLength, out uint pPermittedLspCategories, out int lpErrno);
/// <summary>
/// <para>A pointer to a globally unique identifier (GUID) for the provider.</para>
@ -2322,7 +2322,7 @@ namespace Vanara.PInvoke
// lpProviderId, WSC_PROVIDER_INFO_TYPE InfoType, PBYTE Info, size_t *InfoSize, DWORD Flags, LPINT lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "5880f3dd-2a74-4af8-b0d8-2a8eedccc1e6")]
public static extern SocketError WSCGetProviderInfo(in Guid lpProviderId, WSC_PROVIDER_INFO_TYPE InfoType, [Out] IntPtr Info, ref SizeT InfoSize, uint Flags, out int lpErrno);
public static extern WSRESULT WSCGetProviderInfo(in Guid lpProviderId, WSC_PROVIDER_INFO_TYPE InfoType, [Out] IntPtr Info, ref SizeT InfoSize, uint Flags, out int lpErrno);
/// <summary>
/// <para>A pointer to a globally unique identifier (GUID) for the provider.</para>
@ -2498,7 +2498,7 @@ namespace Vanara.PInvoke
// lpProviderId, WSC_PROVIDER_INFO_TYPE InfoType, PBYTE Info, size_t *InfoSize, DWORD Flags, LPINT lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "91686b38-3cde-4979-8bf6-45e805dd37ff")]
public static extern SocketError WSCGetProviderInfo32(in Guid lpProviderId, WSC_PROVIDER_INFO_TYPE InfoType, [Out] IntPtr Info, ref SizeT InfoSize, uint Flags, out int lpErrno);
public static extern WSRESULT WSCGetProviderInfo32(in Guid lpProviderId, WSC_PROVIDER_INFO_TYPE InfoType, [Out] IntPtr Info, ref SizeT InfoSize, uint Flags, out int lpErrno);
/// <summary>The <c>WSCGetProviderPath</c> function retrieves the DLL path for the specified provider.</summary>
/// <param name="lpProviderId">
@ -2541,7 +2541,7 @@ namespace Vanara.PInvoke
// lpProviderId, WCHAR *lpszProviderDllPath, LPINT lpProviderDllPathLen, LPINT lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "fe60c8c4-e2d0-48cc-9fdf-e58e408fb1b3")]
public static extern SocketError WSCGetProviderPath(in Guid lpProviderId, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpszProviderDllPath, ref int lpProviderDllPathLen, out int lpErrno);
public static extern WSRESULT WSCGetProviderPath(in Guid lpProviderId, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpszProviderDllPath, ref int lpProviderDllPathLen, out int lpErrno);
/// <summary>The <c>WSCGetProviderPath32</c> function retrieves the DLL path for the specified 32-bit provider.</summary>
/// <param name="lpProviderId">Locally unique identifier of the provider. This value is obtained by using WSCEnumProtocols32.</param>
@ -2590,7 +2590,7 @@ namespace Vanara.PInvoke
// lpProviderId, WCHAR *lpszProviderDllPath, LPINT lpProviderDllPathLen, LPINT lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "fd4ef7da-344d-4825-93b2-f0cd5622aeac")]
public static extern SocketError WSCGetProviderPath32(in Guid lpProviderId, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpszProviderDllPath, ref int lpProviderDllPathLen, out int lpErrno);
public static extern WSRESULT WSCGetProviderPath32(in Guid lpProviderId, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder lpszProviderDllPath, ref int lpProviderDllPathLen, out int lpErrno);
/// <summary>
/// The <c>WSCInstallNameSpace</c> function installs a namespace provider. For providers that are able to support multiple
@ -2669,7 +2669,7 @@ namespace Vanara.PInvoke
// lpszIdentifier, LPWSTR lpszPathName, DWORD dwNameSpace, DWORD dwVersion, LPGUID lpProviderId );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "f17f6174-879e-45e7-a250-975d1ee24fe0")]
public static extern SocketError WSCInstallNameSpace([MarshalAs(UnmanagedType.LPWStr)] string lpszIdentifier, [MarshalAs(UnmanagedType.LPWStr)] string lpszPathName, uint dwNameSpace, uint dwVersion, in Guid lpProviderId);
public static extern WSRESULT WSCInstallNameSpace([MarshalAs(UnmanagedType.LPWStr)] string lpszIdentifier, [MarshalAs(UnmanagedType.LPWStr)] string lpszPathName, uint dwNameSpace, uint dwVersion, in Guid lpProviderId);
/// <summary>
/// The <c>WSCInstallNameSpace32</c> function installs a specified 32-bit namespace provider. For providers that are able to support
@ -2756,7 +2756,7 @@ namespace Vanara.PInvoke
// lpszIdentifier, LPWSTR lpszPathName, DWORD dwNameSpace, DWORD dwVersion, LPGUID lpProviderId );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "b107fbe6-bbfb-45be-8419-4d85d3c4e80c")]
public static extern SocketError WSCInstallNameSpace32([MarshalAs(UnmanagedType.LPWStr)] string lpszIdentifier, [MarshalAs(UnmanagedType.LPWStr)] string lpszPathName, uint dwNameSpace, uint dwVersion, in Guid lpProviderId);
public static extern WSRESULT WSCInstallNameSpace32([MarshalAs(UnmanagedType.LPWStr)] string lpszIdentifier, [MarshalAs(UnmanagedType.LPWStr)] string lpszPathName, uint dwNameSpace, uint dwVersion, in Guid lpProviderId);
/// <summary>
/// The <c>WSCInstallNameSpaceEx</c> function installs a namespace provider. For providers that are able to support multiple
@ -2845,7 +2845,7 @@ namespace Vanara.PInvoke
// lpszIdentifier, LPWSTR lpszPathName, DWORD dwNameSpace, DWORD dwVersion, LPGUID lpProviderId, LPBLOB lpProviderSpecific );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "13dde602-c958-4312-a16f-a393dd6fb829")]
public static extern SocketError WSCInstallNameSpaceEx([MarshalAs(UnmanagedType.LPWStr)] string lpszIdentifier, [MarshalAs(UnmanagedType.LPWStr)] string lpszPathName, uint dwNameSpace, uint dwVersion, in Guid lpProviderId, in BLOB lpProviderSpecific);
public static extern WSRESULT WSCInstallNameSpaceEx([MarshalAs(UnmanagedType.LPWStr)] string lpszIdentifier, [MarshalAs(UnmanagedType.LPWStr)] string lpszPathName, uint dwNameSpace, uint dwVersion, in Guid lpProviderId, in BLOB lpProviderSpecific);
/// <summary>
/// <para>
@ -2947,7 +2947,7 @@ namespace Vanara.PInvoke
// lpszIdentifier, LPWSTR lpszPathName, DWORD dwNameSpace, DWORD dwVersion, LPGUID lpProviderId, LPBLOB lpProviderSpecific );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "222ebfcc-8854-4224-b464-28098c84b750")]
public static extern SocketError WSCInstallNameSpaceEx32([MarshalAs(UnmanagedType.LPWStr)] string lpszIdentifier, [MarshalAs(UnmanagedType.LPWStr)] string lpszPathName, uint dwNameSpace, uint dwVersion, in Guid lpProviderId, in BLOB lpProviderSpecific);
public static extern WSRESULT WSCInstallNameSpaceEx32([MarshalAs(UnmanagedType.LPWStr)] string lpszIdentifier, [MarshalAs(UnmanagedType.LPWStr)] string lpszPathName, uint dwNameSpace, uint dwVersion, in Guid lpProviderId, in BLOB lpProviderSpecific);
/// <summary>
/// <para>A pointer to a globally unique identifier (GUID) for the provider.</para>
@ -3074,7 +3074,7 @@ namespace Vanara.PInvoke
// lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "c0736018-2bcf-4281-aa73-3e1ff9eac92e")]
public static extern SocketError WSCInstallProvider(in Guid lpProviderId, [MarshalAs(UnmanagedType.LPWStr)] string lpszProviderDllPath, [MarshalAs(UnmanagedType.LPArray)] WSAPROTOCOL_INFOW[] lpProtocolInfoList, uint dwNumberOfEntries, out int lpErrno);
public static extern WSRESULT WSCInstallProvider(in Guid lpProviderId, [MarshalAs(UnmanagedType.LPWStr)] string lpszProviderDllPath, [MarshalAs(UnmanagedType.LPArray)] WSAPROTOCOL_INFOW[] lpProtocolInfoList, uint dwNumberOfEntries, out int lpErrno);
/// <summary>
/// <para>[**WSCInstallProvider64_32** is no longer available for use as of Windows Vista. Instead, use WSCInstallProvider or WSCInstallProviderAndChains.]</para>
@ -3213,7 +3213,7 @@ namespace Vanara.PInvoke
// lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "50d3a5d1-18f2-439e-a16c-6f31becb1e65")]
public static extern SocketError WSCInstallProvider64_32(in Guid lpProviderId, [MarshalAs(UnmanagedType.LPWStr)] string lpszProviderDllPath, [MarshalAs(UnmanagedType.LPArray)] WSAPROTOCOL_INFOW[] lpProtocolInfoList, uint dwNumberOfEntries, out int lpErrno);
public static extern WSRESULT WSCInstallProvider64_32(in Guid lpProviderId, [MarshalAs(UnmanagedType.LPWStr)] string lpszProviderDllPath, [MarshalAs(UnmanagedType.LPArray)] WSAPROTOCOL_INFOW[] lpProtocolInfoList, uint dwNumberOfEntries, out int lpErrno);
/// <summary>
/// <para>A pointer to a provider-specific, globally unique identifier (GUID).</para>
@ -3408,7 +3408,7 @@ namespace Vanara.PInvoke
// lpProtocolInfoList, DWORD dwNumberOfEntries, LPDWORD lpdwCatalogEntryId, LPINT lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "592f48b4-5826-449f-b5cc-b0990679fe9f")]
public static extern SocketError WSCInstallProviderAndChains64_32(in Guid lpProviderId, [MarshalAs(UnmanagedType.LPWStr)] string lpszProviderDllPath, [MarshalAs(UnmanagedType.LPWStr)] string lpszLspName, XP1 dwServiceFlags,
public static extern WSRESULT WSCInstallProviderAndChains64_32(in Guid lpProviderId, [MarshalAs(UnmanagedType.LPWStr)] string lpszProviderDllPath, [MarshalAs(UnmanagedType.LPWStr)] string lpszLspName, XP1 dwServiceFlags,
[MarshalAs(UnmanagedType.LPArray)] WSAPROTOCOL_INFOW[] lpProtocolInfoList, uint dwNumberOfEntries, out uint lpdwCatalogEntryId, out int lpErrno);
/// <summary>
@ -3617,7 +3617,7 @@ namespace Vanara.PInvoke
// lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "266c9424-f6ab-4630-843d-bc0833d74e4f")]
public static extern SocketError WSCSetApplicationCategory([MarshalAs(UnmanagedType.LPWStr)] string Path, uint PathLength, [MarshalAs(UnmanagedType.LPWStr)] string Extra, uint ExtraLength, uint PermittedLspCategories, out uint pPrevPermLspCat, out int lpErrno);
public static extern WSRESULT WSCSetApplicationCategory([MarshalAs(UnmanagedType.LPWStr)] string Path, uint PathLength, [MarshalAs(UnmanagedType.LPWStr)] string Extra, uint ExtraLength, uint PermittedLspCategories, out uint pPrevPermLspCat, out int lpErrno);
/// <summary>
/// <para>A pointer to a globally unique identifier (GUID) for the provider.</para>
@ -3787,7 +3787,7 @@ namespace Vanara.PInvoke
// lpProviderId, WSC_PROVIDER_INFO_TYPE InfoType, PBYTE Info, size_t InfoSize, DWORD Flags, LPINT lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "10eed3e6-d5a0-4ba4-964e-3d924a231afb")]
public static extern SocketError WSCSetProviderInfo(in Guid lpProviderId, WSC_PROVIDER_INFO_TYPE InfoType, IntPtr Info, SizeT InfoSize, uint Flags, out int lpErrno);
public static extern WSRESULT WSCSetProviderInfo(in Guid lpProviderId, WSC_PROVIDER_INFO_TYPE InfoType, IntPtr Info, SizeT InfoSize, uint Flags, out int lpErrno);
/// <summary>
/// <para>A pointer to a globally unique identifier (GUID) for the provider.</para>
@ -3957,7 +3957,7 @@ namespace Vanara.PInvoke
// lpProviderId, WSC_PROVIDER_INFO_TYPE InfoType, PBYTE Info, size_t InfoSize, DWORD Flags, LPINT lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "adb2737f-5327-4306-bd57-f165f339f911")]
public static extern SocketError WSCSetProviderInfo32(in Guid lpProviderId, WSC_PROVIDER_INFO_TYPE InfoType, IntPtr Info, SizeT InfoSize, uint Flags, out int lpErrno);
public static extern WSRESULT WSCSetProviderInfo32(in Guid lpProviderId, WSC_PROVIDER_INFO_TYPE InfoType, IntPtr Info, SizeT InfoSize, uint Flags, out int lpErrno);
/// <summary>The <c>WSCUnInstallNameSpace</c> function uninstalls the indicated name-space provider.</summary>
/// <param name="lpProviderId">A pointer to a globally unique identifier (GUID) for the name-space provider to be uninstalled.</param>
@ -4023,7 +4023,7 @@ namespace Vanara.PInvoke
// lpProviderId );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "5267f986-99fc-4e53-9fbb-3850bb9d24cf")]
public static extern SocketError WSCUnInstallNameSpace(in Guid lpProviderId);
public static extern WSRESULT WSCUnInstallNameSpace(in Guid lpProviderId);
/// <summary>The <c>WSCUnInstallNameSpace32</c> function uninstalls a specific 32-bit namespace provider.</summary>
/// <param name="lpProviderId">A pointer to a globally unique identifier (GUID) for the name-space provider to be uninstalled.</param>
@ -4095,7 +4095,7 @@ namespace Vanara.PInvoke
// lpProviderId );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "a2a08159-6ac0-493d-8f9f-d19aa199a65f")]
public static extern SocketError WSCUnInstallNameSpace32(in Guid lpProviderId);
public static extern WSRESULT WSCUnInstallNameSpace32(in Guid lpProviderId);
/// <summary>The <c>WSCUpdateProvider</c> function modifies the specified transport provider in the system configuration database.</summary>
/// <param name="lpProviderId">A pointer to a globally unique identifier (GUID) for the provider.</param>
@ -4185,7 +4185,7 @@ namespace Vanara.PInvoke
// const WCHAR *lpszProviderDllPath, const LPWSAPROTOCOL_INFOW lpProtocolInfoList, DWORD dwNumberOfEntries, LPINT lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "7777a2ff-2ece-4f28-88af-87fc96fdda9f")]
public static extern SocketError WSCUpdateProvider(in Guid lpProviderId, [MarshalAs(UnmanagedType.LPWStr)] string lpszProviderDllPath, [MarshalAs(UnmanagedType.LPArray)] WSAPROTOCOL_INFOW[] lpProtocolInfoList, uint dwNumberOfEntries, out int lpErrno);
public static extern WSRESULT WSCUpdateProvider(in Guid lpProviderId, [MarshalAs(UnmanagedType.LPWStr)] string lpszProviderDllPath, [MarshalAs(UnmanagedType.LPArray)] WSAPROTOCOL_INFOW[] lpProtocolInfoList, uint dwNumberOfEntries, out int lpErrno);
/// <summary>
/// The <c>WSCUpdateProvider32</c> function modifies the specified 32-bit transport provider in the system configuration database.
@ -4285,7 +4285,7 @@ namespace Vanara.PInvoke
// lpErrno );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2spi.h", MSDNShortId = "803ef58a-853b-491c-bed1-e02275fef258")]
public static extern SocketError WSCUpdateProvider32(in Guid lpProviderId, [MarshalAs(UnmanagedType.LPWStr)] string lpszProviderDllPath, [MarshalAs(UnmanagedType.LPArray)] WSAPROTOCOL_INFOW[] lpProtocolInfoList, uint dwNumberOfEntries, out int lpErrno);
public static extern WSRESULT WSCUpdateProvider32(in Guid lpProviderId, [MarshalAs(UnmanagedType.LPWStr)] string lpszProviderDllPath, [MarshalAs(UnmanagedType.LPArray)] WSAPROTOCOL_INFOW[] lpProtocolInfoList, uint dwNumberOfEntries, out int lpErrno);
/// <summary>
/// The <c>AFPROTOCOLS</c> structure supplies a list of protocols to which application programmers can constrain queries. The

View File

@ -141,7 +141,7 @@ namespace Vanara.PInvoke
// LPHANDLE lpHandle );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2tcpip.h", MSDNShortId = "A4DE552D-DEA7-44F5-865F-5B02C9BB4AB6")]
public static extern SocketError GetAddrInfoExCancel(in HANDLE lpHandle);
public static extern WSRESULT GetAddrInfoExCancel(in HANDLE lpHandle);
/// <summary>
/// The <c>GetAddrInfoExOverlappedResult</c> function gets the return code for an <c>OVERLAPPED</c> structure used by an
@ -170,7 +170,7 @@ namespace Vanara.PInvoke
// GetAddrInfoExOverlappedResult( LPOVERLAPPED lpOverlapped );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2tcpip.h", MSDNShortId = "BBA6E407-561C-4B3C-9218-0047477E82DE")]
public static extern SocketError GetAddrInfoExOverlappedResult(IntPtr lpOverlapped);
public static extern WSRESULT GetAddrInfoExOverlappedResult(IntPtr lpOverlapped);
/// <summary>
/// The <c>GetAddrInfoExOverlappedResult</c> function gets the return code for an <c>OVERLAPPED</c> structure used by an
@ -199,7 +199,7 @@ namespace Vanara.PInvoke
// GetAddrInfoExOverlappedResult( LPOVERLAPPED lpOverlapped );
[DllImport(Lib.Ws2_32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("ws2tcpip.h", MSDNShortId = "BBA6E407-561C-4B3C-9218-0047477E82DE")]
public static unsafe extern SocketError GetAddrInfoExOverlappedResult(NativeOverlapped* lpOverlapped);
public static unsafe extern WSRESULT GetAddrInfoExOverlappedResult(NativeOverlapped* lpOverlapped);
/// <summary>
/// The <c>GetAddrInfoEx</c> function provides protocol-independent name resolution with additional parameters to qualify which
@ -865,7 +865,7 @@ namespace Vanara.PInvoke
// LPOVERLAPPED lpOverlapped, LPLOOKUPSERVICE_COMPLETION_ROUTINE lpCompletionRoutine, LPHANDLE lpNameHandle );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("ws2tcpip.h", MSDNShortId = "cc4ccb2d-ea5a-48bd-a3ae-f70432ab2c39")]
public static unsafe extern SocketError GetAddrInfoExW([Optional, MarshalAs(UnmanagedType.LPWStr)] string pName, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pServiceName,
public static unsafe extern WSRESULT GetAddrInfoExW([Optional, MarshalAs(UnmanagedType.LPWStr)] string pName, [Optional, MarshalAs(UnmanagedType.LPWStr)] string pServiceName,
[Optional] NS dwNameSpace, [In, Optional] Guid* lpNspId, [In, Optional] ADDRINFOEXW* hints, out SafeADDRINFOEXWArray ppResult, [In, Optional] TIMEVAL* timeout, [In, Optional] NativeOverlapped* lpOverlapped,
[In, Optional] LPLOOKUPSERVICE_COMPLETION_ROUTINE lpCompletionRoutine, [Out, Optional] HANDLE* lpNameHandle);
@ -1345,7 +1345,7 @@ namespace Vanara.PInvoke
// PCWSTR pServiceName, const ADDRINFOW *pHints, PADDRINFOW *ppResult );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("ws2tcpip.h", MSDNShortId = "82436a88-5b37-4758-a5c9-b60dd1cbc36c")]
public static extern SocketError GetAddrInfoW([Optional] string pNodeName, [Optional] string pServiceName, [Optional] in ADDRINFOW pHints, out SafeADDRINFOWArray ppResult);
public static extern WSRESULT GetAddrInfoW([Optional] string pNodeName, [Optional] string pServiceName, [Optional] in ADDRINFOW pHints, out SafeADDRINFOWArray ppResult);
/// <summary>The <c>getipv4sourcefilter</c> inline function retrieves the multicast filter state for an IPv4 socket.</summary>
/// <param name="Socket">A descriptor that identifies a multicast socket.</param>
@ -1420,14 +1420,14 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getipv4sourcefilter int getipv4sourcefilter( SOCKET
// Socket, IN_ADDR Interface, IN_ADDR Group, MULTICAST_MODE_TYPE *FilterMode, ULONG *SourceCount, IN_ADDR *SourceList );
[PInvokeData("ws2tcpip.h", MSDNShortId = "17D35D24-C419-4787-AB93-E6B1B6B13807")]
public static SocketError getipv4sourcefilter(SOCKET Socket, IN_ADDR Interface, IN_ADDR Group, out MULTICAST_MODE_TYPE FilterMode, ref int SourceCount, IN_ADDR[] SourceList)
public static WSRESULT getipv4sourcefilter(SOCKET Socket, IN_ADDR Interface, IN_ADDR Group, out MULTICAST_MODE_TYPE FilterMode, ref int SourceCount, IN_ADDR[] SourceList)
{
FilterMode = MULTICAST_MODE_TYPE.MCAST_INCLUDE;
if (SourceCount > (SourceList?.Length ?? 0))
{
WSASetLastError(System.Net.Sockets.SocketError.NoBufferSpaceAvailable);
return System.Net.Sockets.SocketError.SocketError;
WSASetLastError(WSRESULT.WSAENOBUFS);
return SOCKET_ERROR;
}
var Filter = new IP_MSFILTER
@ -1644,7 +1644,7 @@ namespace Vanara.PInvoke
// INT Flags );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("ws2tcpip.h", MSDNShortId = "5630a49a-c182-440c-ad54-6ff3ba4274c6")]
public static extern SocketError GetNameInfoW([In] SOCKADDR pSockaddr, int SockaddrLength, StringBuilder pNodeBuffer, uint NodeBufferSize, StringBuilder pServiceBuffer, uint ServiceBufferSize, NI Flags);
public static extern WSRESULT GetNameInfoW([In] SOCKADDR pSockaddr, int SockaddrLength, StringBuilder pNodeBuffer, uint NodeBufferSize, StringBuilder pServiceBuffer, uint ServiceBufferSize, NI Flags);
/// <summary>The <c>getsourcefilter</c> inline function retrieves the multicast filter state for an IPv4 or IPv6 socket.</summary>
/// <param name="Socket">A descriptor that identifies a multicast socket.</param>
@ -1710,14 +1710,14 @@ namespace Vanara.PInvoke
// Interface, const SOCKADDR *Group, int GroupLength, MULTICAST_MODE_TYPE *FilterMode, ULONG *SourceCount, SOCKADDR_STORAGE
// *SourceList );
[PInvokeData("ws2tcpip.h", MSDNShortId = "2CA84000-F114-439D-BEDE-9990044C7785")]
public static SocketError getsourcefilter(SOCKET Socket, uint Interface, [In] SOCKADDR Group, int GroupLength, out MULTICAST_MODE_TYPE FilterMode, ref int SourceCount, SOCKADDR_STORAGE[] SourceList)
public static WSRESULT getsourcefilter(SOCKET Socket, uint Interface, [In] SOCKADDR Group, int GroupLength, out MULTICAST_MODE_TYPE FilterMode, ref int SourceCount, SOCKADDR_STORAGE[] SourceList)
{
FilterMode = MULTICAST_MODE_TYPE.MCAST_INCLUDE;
if (SourceCount > SourceList.Length || GroupLength > Group.Size)
{
WSASetLastError(System.Net.Sockets.SocketError.NoBufferSpaceAvailable);
return System.Net.Sockets.SocketError.SocketError;
WSASetLastError(WSRESULT.WSAENOBUFS);
return SOCKET_ERROR;
}
var Filter = new GROUP_FILTER
@ -2163,7 +2163,7 @@ namespace Vanara.PInvoke
// pszAddrString, PVOID pAddrBuf );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Ansi)]
[PInvokeData("ws2tcpip.h", MSDNShortId = "d0705997-0dc7-443b-a43f-611301cc9169")]
public static extern SocketError inet_pton(ADDRESS_FAMILY Family, string pszAddrString, out IN_ADDR pAddrBuf);
public static extern WSRESULT inet_pton(ADDRESS_FAMILY Family, string pszAddrString, out IN_ADDR pAddrBuf);
/// <summary>
/// The <c>InetPton</c> function converts an IPv4 or IPv6 Internet network address in its standard text presentation form into its
@ -2306,7 +2306,7 @@ namespace Vanara.PInvoke
// pszAddrString, PVOID pAddrBuf );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Ansi)]
[PInvokeData("ws2tcpip.h", MSDNShortId = "d0705997-0dc7-443b-a43f-611301cc9169")]
public static extern SocketError inet_pton(ADDRESS_FAMILY Family, string pszAddrString, out IN6_ADDR pAddrBuf);
public static extern WSRESULT inet_pton(ADDRESS_FAMILY Family, string pszAddrString, out IN6_ADDR pAddrBuf);
/// <summary>
/// The <c>InetNtop</c> function converts an IPv4 or IPv6 Internet network address into a string in Internet standard format. The
@ -2727,7 +2727,7 @@ namespace Vanara.PInvoke
// pszAddrString, PVOID pAddrBuf );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("ws2tcpip.h", MSDNShortId = "d0705997-0dc7-443b-a43f-611301cc9169")]
public static extern SocketError InetPtonW(ADDRESS_FAMILY Family, [MarshalAs(UnmanagedType.LPWStr)] string pszAddrString, out IN_ADDR pAddrBuf);
public static extern WSRESULT InetPtonW(ADDRESS_FAMILY Family, [MarshalAs(UnmanagedType.LPWStr)] string pszAddrString, out IN_ADDR pAddrBuf);
/// <summary>
/// The <c>InetPton</c> function converts an IPv4 or IPv6 Internet network address in its standard text presentation form into its
@ -2870,7 +2870,7 @@ namespace Vanara.PInvoke
// pszAddrString, PVOID pAddrBuf );
[DllImport(Lib.Ws2_32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
[PInvokeData("ws2tcpip.h", MSDNShortId = "d0705997-0dc7-443b-a43f-611301cc9169")]
public static extern SocketError InetPtonW(ADDRESS_FAMILY Family, [MarshalAs(UnmanagedType.LPWStr)] string pszAddrString, out IN6_ADDR pAddrBuf);
public static extern WSRESULT InetPtonW(ADDRESS_FAMILY Family, [MarshalAs(UnmanagedType.LPWStr)] string pszAddrString, out IN6_ADDR pAddrBuf);
/// <summary>
/// The <c>SetAddrInfoEx</c> function registers or deregisters a name, a service name, and associated addresses with a specific
@ -3046,7 +3046,7 @@ namespace Vanara.PInvoke
// lpNameHandle );
[DllImport(Lib.Ws2_32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("ws2tcpip.h", MSDNShortId = "6d3c5b97-32ce-4eb5-a047-d9b37c37cdda")]
public static extern SocketError SetAddrInfoEx([MarshalAs(UnmanagedType.LPTStr)] string pName, [Optional, MarshalAs(UnmanagedType.LPTStr)] string pServiceName,
public static extern WSRESULT SetAddrInfoEx([MarshalAs(UnmanagedType.LPTStr)] string pName, [Optional, MarshalAs(UnmanagedType.LPTStr)] string pServiceName,
[In, Optional, MarshalAs(UnmanagedType.LPArray)] SOCKET_ADDRESS[] pAddresses, [Optional] uint dwAddressCount, [In, Optional] IntPtr lpBlob, [Optional] uint dwFlags, [Optional] NS dwNameSpace,
in Guid lpNspId, in TIMEVAL timeout, [In, Optional] IntPtr lpOverlapped, [In, Optional] LPLOOKUPSERVICE_COMPLETION_ROUTINE lpCompletionRoutine, out HANDLE lpNameHandle);
@ -3224,7 +3224,7 @@ namespace Vanara.PInvoke
// lpNameHandle );
[DllImport(Lib.Ws2_32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("ws2tcpip.h", MSDNShortId = "6d3c5b97-32ce-4eb5-a047-d9b37c37cdda")]
public static unsafe extern SocketError SetAddrInfoEx([MarshalAs(UnmanagedType.LPTStr)] string pName, [Optional, MarshalAs(UnmanagedType.LPTStr)] string pServiceName,
public static unsafe extern WSRESULT SetAddrInfoEx([MarshalAs(UnmanagedType.LPTStr)] string pName, [Optional, MarshalAs(UnmanagedType.LPTStr)] string pServiceName,
[In, Optional, MarshalAs(UnmanagedType.LPArray)] SOCKET_ADDRESS[] pAddresses, [Optional] uint dwAddressCount, [In, Optional] IntPtr lpBlob,
[Optional] uint dwFlags, [Optional] NS dwNameSpace, [In, Optional] Guid* lpNspId, [In, Optional] TIMEVAL* timeout,
[In, Optional] NativeOverlapped* lpOverlapped, [In, Optional] LPLOOKUPSERVICE_COMPLETION_ROUTINE lpCompletionRoutine, [Out, Optional] HANDLE* lpNameHandle);
@ -3282,12 +3282,12 @@ namespace Vanara.PInvoke
// https://docs.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-setipv4sourcefilter int setipv4sourcefilter( SOCKET
// Socket, IN_ADDR Interface, IN_ADDR Group, MULTICAST_MODE_TYPE FilterMode, ULONG SourceCount, const IN_ADDR *SourceList );
[PInvokeData("ws2tcpip.h", MSDNShortId = "C296D050-9195-42B5-8EBE-C6004F2DA855")]
public static SocketError setipv4sourcefilter(SOCKET Socket, IN_ADDR Interface, IN_ADDR Group, MULTICAST_MODE_TYPE FilterMode, uint SourceCount, IN_ADDR[] SourceList)
public static WSRESULT setipv4sourcefilter(SOCKET Socket, IN_ADDR Interface, IN_ADDR Group, MULTICAST_MODE_TYPE FilterMode, uint SourceCount, IN_ADDR[] SourceList)
{
if (SourceCount > SourceList.Length)
{
WSASetLastError(System.Net.Sockets.SocketError.NoBufferSpaceAvailable);
return System.Net.Sockets.SocketError.SocketError;
WSASetLastError(WSRESULT.WSAENOBUFS);
return SOCKET_ERROR;
}
var Filter = new IP_MSFILTER
@ -3346,12 +3346,12 @@ namespace Vanara.PInvoke
// Interface, const SOCKADDR *Group, int GroupLength, MULTICAST_MODE_TYPE FilterMode, ULONG SourceCount, const SOCKADDR_STORAGE
// *SourceList );
[PInvokeData("ws2tcpip.h", MSDNShortId = "320455F3-FDFB-46C6-9F26-3C60064A2CB0")]
public static SocketError setsourcefilter(SOCKET Socket, uint Interface, [In] SOCKADDR Group, int GroupLength, MULTICAST_MODE_TYPE FilterMode, uint SourceCount, SOCKADDR_STORAGE[] SourceList)
public static WSRESULT setsourcefilter(SOCKET Socket, uint Interface, [In] SOCKADDR Group, int GroupLength, MULTICAST_MODE_TYPE FilterMode, uint SourceCount, SOCKADDR_STORAGE[] SourceList)
{
if (SourceCount > SourceList.Length || GroupLength > Group.Size)
{
WSASetLastError(System.Net.Sockets.SocketError.NoBufferSpaceAvailable);
return System.Net.Sockets.SocketError.SocketError;
WSASetLastError(WSRESULT.WSAENOBUFS);
return SOCKET_ERROR;
}
var Filter = new GROUP_FILTER