1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-11 04:52:21 +02:00

Merge pull request #1138 from damianday/patch-5

Update Socket.bf
This commit is contained in:
Brian Fiete 2021-08-29 06:15:21 -07:00 committed by GitHub
commit 0d64d35ced
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,7 @@ namespace System.Net
{ {
class Socket class Socket
{ {
const uint16 WINSOCK_VERSION = 0x0202;
const int32 WSAENETRESET = 10052; const int32 WSAENETRESET = 10052;
const int32 WSAECONNABORTED = 10053; const int32 WSAECONNABORTED = 10053;
const int32 WSAECONNRESET = 10054; const int32 WSAECONNRESET = 10054;
@ -169,6 +170,9 @@ namespace System.Net
#if BF_PLATFORM_WINDOWS #if BF_PLATFORM_WINDOWS
[Import("wsock32.lib"), CLink, CallingConvention(.Stdcall)] [Import("wsock32.lib"), CLink, CallingConvention(.Stdcall)]
static extern int32 WSAStartup(uint16 versionRequired, WSAData* wsaData); static extern int32 WSAStartup(uint16 versionRequired, WSAData* wsaData);
[Import("wsock32.lib"), CLink, CallingConvention(.Stdcall)]
static extern int32 WSACleanup();
[Import("wsock32.lib"), CLink, CallingConvention(.Stdcall)] [Import("wsock32.lib"), CLink, CallingConvention(.Stdcall)]
static extern int32 WSAGetLastError(); static extern int32 WSAGetLastError();
@ -230,11 +234,22 @@ namespace System.Net
#endif #endif
} }
public static void Init() public static int32 Init(uint16 versionRequired = WINSOCK_VERSION)
{ {
#if BF_PLATFORM_WINDOWS #if BF_PLATFORM_WINDOWS
WSAData wsaData = default; WSAData wsaData = default;
WSAStartup(0x202, &wsaData); return WSAStartup(versionRequired, &wsaData);
#else
return 0;
#endif
}
public static int32 Uninit()
{
#if BF_PLATFORM_WINDOWS
return WSACleanup();
#else
return 0;
#endif #endif
} }