From 9008b3cadf09c1f92bff3fb60e0c7ef09e79d059 Mon Sep 17 00:00:00 2001 From: proller Date: Wed, 21 May 2014 00:25:51 +0400 Subject: [PATCH 1/6] Try to add windows tcpip headers --- include/enet/win32.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/enet/win32.h b/include/enet/win32.h index e73ca9d0..6f304ccf 100644 --- a/include/enet/win32.h +++ b/include/enet/win32.h @@ -14,6 +14,17 @@ #endif #endif + +#ifndef WIN32_LEAN_AND_MEAN + #define WIN32_LEAN_AND_MEAN +#endif +#ifndef _WIN32_WINNT + #define _WIN32_WINNT 0x0501 +#endif +#define NOMINMAX +#include +#include + #include #include From eba42ff2d10901fbccb209e9f6df3fdc4b70a792 Mon Sep 17 00:00:00 2001 From: proller Date: Wed, 21 May 2014 00:35:29 +0400 Subject: [PATCH 2/6] Revert "Try to add windows tcpip headers" This reverts commit 9008b3cadf09c1f92bff3fb60e0c7ef09e79d059. --- include/enet/win32.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/include/enet/win32.h b/include/enet/win32.h index 6f304ccf..e73ca9d0 100644 --- a/include/enet/win32.h +++ b/include/enet/win32.h @@ -14,17 +14,6 @@ #endif #endif - -#ifndef WIN32_LEAN_AND_MEAN - #define WIN32_LEAN_AND_MEAN -#endif -#ifndef _WIN32_WINNT - #define _WIN32_WINNT 0x0501 -#endif -#define NOMINMAX -#include -#include - #include #include From 4133fd26b810f23108f776a1059e44f7ce199f74 Mon Sep 17 00:00:00 2001 From: proller Date: Thu, 10 Apr 2014 22:56:28 +0400 Subject: [PATCH 3/6] add CMakeLists.txt --- CMakeLists.txt | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..ce6dc8ff --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,57 @@ +cmake_minimum_required(VERSION 2.6) + +project(enet) + +# The "configure" step. +include(CheckFunctionExists) +include(CheckStructHasMember) +include(CheckTypeSize) +check_function_exists("fcntl" HAS_FCNTL) +check_function_exists("poll" HAS_POLL) +check_function_exists("gethostbyname_r" HAS_GETHOSTBYNAME_R) +check_function_exists("gethostbyaddr_r" HAS_GETHOSTBYADDR_R) +check_function_exists("inet_pton" HAS_INET_PTON) +check_function_exists("inet_ntop" HAS_INET_NTOP) +check_struct_has_member("struct msghdr" "msg_flags" "sys/types.h;sys/socket.h" HAS_MSGHDR_FLAGS) +set(CMAKE_EXTRA_INCLUDE_FILES "sys/types.h" "sys/socket.h") +check_type_size("socklen_t" HAS_SOCKLEN_T BUILTIN_TYPES_ONLY) +unset(CMAKE_EXTRA_INCLUDE_FILES) + +if(HAS_FCNTL) + add_definitions(-DHAS_FCNTL=1) +endif() +if(HAS_POLL) + add_definitions(-DHAS_POLL=1) +endif() +if(HAS_GETHOSTBYNAME_R) + add_definitions(-DHAS_GETHOSTBYNAME_R=1) +endif() +if(HAS_GETHOSTBYADDR_R) + add_definitions(-DHAS_GETHOSTBYADDR_R=1) +endif() +if(HAS_INET_PTON) + add_definitions(-DHAS_INET_PTON=1) +endif() +if(HAS_INET_NTOP) + add_definitions(-DHAS_INET_NTOP=1) +endif() +if(HAS_MSGHDR_FLAGS) + add_definitions(-DHAS_MSGHDR_FLAGS=1) +endif() +if(HAS_SOCKLEN_T) + add_definitions(-DHAS_SOCKLEN_T=1) +endif() + +include_directories(${PROJECT_SOURCE_DIR}/include) + +add_library(enet STATIC + callbacks.c + compress.c + host.c + list.c + packet.c + peer.c + protocol.c + unix.c + win32.c + ) From 99004c45ac9a8c1802b49270a1437a418414435f Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Wed, 28 May 2014 21:16:14 +0300 Subject: [PATCH 4/6] include mmsystem.h for timeGetTime --- win32.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/win32.c b/win32.c index 04c72466..5cc16799 100644 --- a/win32.c +++ b/win32.c @@ -4,9 +4,10 @@ */ #ifdef _WIN32 -#include #define ENET_BUILDING_LIB 1 #include "enet/enet.h" +#include +#include static enet_uint32 timeBase = 0; From d85a037ec4db1ba0996bf94385b8f9b4f10b41e7 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Sun, 7 Sep 2014 12:14:10 +0300 Subject: [PATCH 5/6] add premake file --- premake4.lua | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 premake4.lua diff --git a/premake4.lua b/premake4.lua new file mode 100644 index 00000000..0e6e7adf --- /dev/null +++ b/premake4.lua @@ -0,0 +1,59 @@ +solution "enet" + configurations { "Debug", "Release" } + platforms { "x32", "x64" } + + project "enet_static" + kind "StaticLib" + language "C" + + files { "*.c" } + + includedirs { "include/" } + + configuration "Debug" + targetsuffix "d" + + defines({ "DEBUG" }) + + flags { "Symbols" } + + configuration "Release" + defines({ "NDEBUG" }) + + flags { "Optimize" } + + configuration { "Debug", "x64" } + targetsuffix "64d" + + configuration { "Release", "x64" } + targetsuffix "64" + + project "enet" + kind "SharedLib" + language "C" + + files { "*.c" } + + includedirs { "include/" } + + defines({"ENET_DLL=1" }) + + configuration "Debug" + targetsuffix "d" + + defines({ "DEBUG" }) + + flags { "Symbols" } + + configuration "Release" + defines({ "NDEBUG" }) + + flags { "Optimize" } + + configuration { "Debug", "x64" } + targetsuffix "64d" + + configuration { "Release", "x64" } + targetsuffix "64" + + \ No newline at end of file From 6ef4e7d277a4f9e97e24e3f3b77835f584acd9a1 Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Mon, 29 Sep 2014 15:49:34 +0300 Subject: [PATCH 6/6] limit number of packets that can be received per iteration of protocol loop --- protocol.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/protocol.c b/protocol.c index 101d923e..3a7dd368 100644 --- a/protocol.c +++ b/protocol.c @@ -1191,7 +1191,9 @@ enet_protocol_handle_incoming_commands (ENetHost * host, ENetEvent * event) static int enet_protocol_receive_incoming_commands (ENetHost * host, ENetEvent * event) { - for (;;) + int packets; + + for (packets = 0; packets < 256; ++ packets) { int receivedLength; ENetBuffer buffer;