/// <summary> /// Initiates use of the Winsock DLL by the current process. /// </summary> /// <param name="requestedVersion"> /// Type: <see cref="yourmt.Sockets.WinSockVersion"/> /// The requested <see cref="WinSockVersion"/>. /// </param> public WsaWrapper(WinSockVersion requestedVersion) { _data = new WsaData(); Int32 res = WinSock2.WSAStartup(requestedVersion, ref _data); if(res != 0) throw new Win32Exception(res); // WSAStartup returns the error value by itself }
public static extern Int32 WSAStartup(WinSockVersion wVersionRequested, ref WsaData wsaData);
public static extern int WSAStartup( UInt16 wVersionRequested, WsaData wsaData);
private static extern int WSAStartup(short wVersionRequested, ref WsaData lpWSAData);
static extern int WSAStartup(Int16 wVersionRequested, ref WsaData lpWSAData);
public DiscoveryBase() { lock (refCountLock) { if (refCount == 0) { WsaData WinsockVersion = new WsaData(); int ret = WSAStartup(UnsafePnrpNativeMethods.RequiredWinsockVersion, ref WinsockVersion); if (ret != 0) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SocketException(ret)); } } refCount++; } }