-#define __statement __extension__ // To compile for Android/X86 (Need to add support to eC)
- // Also had to add __extension__ to __swap16md macro in endian.h
+#ifdef __statement
+#undef __statement
+#endif
+#define __statement(x) __extension__(x) // To compile for Android/X86 (Need to add support to eC)
+ // Also had to add __extension__ to __swap16md macro in endian.h
namespace net;
#ifndef ECERE_NONET
#if defined(__WIN32__)
-
+#define SOCKLEN_TYPE int
#define WIN32_LEAN_AND_MEAN
#define String _String
#include <winsock.h>
#undef String
-static WSADATA wsaData;
#elif defined(__unix__) || defined(__APPLE__)
default:
+#define SOCKLEN_TYPE socklen_t
#define set _set
#define uint _uint
#include <sys/time.h>
import "network"
+#ifdef __ANDROID__
+// TOFIX:
+#undef ntohs
+#undef htons
+#define ntohs(x) (x)
+#define htons(x) (x)
+#endif
+
public class Service
{
public:
#if defined(__WIN32__) || defined(__unix__) || defined(__APPLE__)
SOCKET s;
+ if(this.s != -1)
+ return false; // Already started
+
#ifdef DEBUG_SOCKETS
Log("[P] [NStartService]\n");
#endif
sockets.Clear();
// Fix up the links/offsets here...
- sockets.offset = (uint)&((Socket)0).prev;
+ sockets.offset = (uint)(uintptr)&((Socket)0).prev;
FD_SET(s, &network.readSet);
FD_SET(s, &network.exceptSet);
{
SOCKET s;
SOCKADDR_IN a;
- int addrLen = sizeof(a);
+ SOCKLEN_TYPE addrLen = sizeof(a);
s = accept(this.s,(SOCKADDR *)&a,&addrLen);
closesocket(s);
}