From 9657cdd55b634a0c8259e96480a677c11148191c Mon Sep 17 00:00:00 2001 From: subuzero Date: Wed, 4 Mar 2020 00:43:04 +0530 Subject: [PATCH] Fix for Socket class on linux. closesocket() is windows only. --- BeefLibs/corlib/src/Net/Socket.bf | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/BeefLibs/corlib/src/Net/Socket.bf b/BeefLibs/corlib/src/Net/Socket.bf index 07d3dbee..792ba423 100644 --- a/BeefLibs/corlib/src/Net/Socket.bf +++ b/BeefLibs/corlib/src/Net/Socket.bf @@ -146,10 +146,13 @@ namespace System.Net [CLink, StdCall] internal static extern int32 connect(HSocket s, SockAddr* name, int32 nameLen); - +#if BF_PLATFORM_WINDOWS [CLink, StdCall] internal static extern int32 closesocket(HSocket s); - +#else + [CLink, StdCall] + internal static extern int32 close(HSocket s); +#endif [CLink, StdCall] internal static extern int32 bind(HSocket s, SockAddr* name, int32 nameLen); @@ -174,7 +177,11 @@ namespace System.Net public ~this() { if (mHandle != INVALID_SOCKET) +#if BF_PLATFORM_WINDOWS closesocket(mHandle); +#else + close(mHandle); +#endif } public static void Init() @@ -352,7 +359,11 @@ namespace System.Net public void Close() { mIsConnected = false; +#if BF_PLATFORM_WINDOWS closesocket(mHandle); +#else + close(mHandle); +#endif mHandle = INVALID_SOCKET; } @@ -365,3 +376,4 @@ namespace System.Net } } } +