From 3faab1b019c231f20c3d80e9c9c36cc7f3e88d63 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Sun, 19 Feb 2017 12:08:58 -0800 Subject: [PATCH] adjusted clsocket build and test, so there is an EchoServer and QueryDayTime sending a string to the EchoServer. --- build3/premake4.lua | 17 +++++-- examples/ThirdPartyLibs/clsocket/premake4.lua | 2 +- test/clsocket/EchoServer.cpp | 4 ++ test/clsocket/QueryDayTime.cpp | 8 +-- test/clsocket/premake4.lua | 51 +++++++++++++++++++ 5 files changed, 74 insertions(+), 8 deletions(-) create mode 100644 test/clsocket/premake4.lua diff --git a/build3/premake4.lua b/build3/premake4.lua index a5187efa7..345091d3e 100644 --- a/build3/premake4.lua +++ b/build3/premake4.lua @@ -71,10 +71,17 @@ description = "Don't build Extras" } + newoption + { + trigger = "no-clsocket", + description = "Disable clsocket and clsocket tests (used for optional TCP networking in pybullet and shared memory C-API)" + } + + newoption { trigger = "no-enet", - description = "Disable enet and enet tests" + description = "Disable enet and enet tests (used for optional UDP networking in pybullet and shared memory C-API)" } newoption @@ -271,18 +278,20 @@ end include "../examples/ThirdPartyLibs/midi" end - if not _OPTIONS["no_clsocket"] then - include "../examples/ThirdPartyLibs/clsocket" + if not _OPTIONS["no-clsocket"] then defines {"BT_ENABLE_CLSOCKET"} + include "../examples/ThirdPartyLibs/clsocket" + include "../test/clsocket" end if not _OPTIONS["no-enet"] then + defines {"BT_ENABLE_ENET"} + include "../examples/ThirdPartyLibs/enet" include "../test/enet/nat_punchthrough/client" include "../test/enet/nat_punchthrough/server" include "../test/enet/chat/client" include "../test/enet/chat/server" - defines {"BT_ENABLE_ENET"} end if _OPTIONS["no-bullet3"] then diff --git a/examples/ThirdPartyLibs/clsocket/premake4.lua b/examples/ThirdPartyLibs/clsocket/premake4.lua index 896185095..57447b1fa 100644 --- a/examples/ThirdPartyLibs/clsocket/premake4.lua +++ b/examples/ThirdPartyLibs/clsocket/premake4.lua @@ -14,7 +14,7 @@ includedirs { - ".","include" + ".","include","src" } files { "src/SimpleSocket.cpp", diff --git a/test/clsocket/EchoServer.cpp b/test/clsocket/EchoServer.cpp index 4a27d278f..4173e5e6a 100644 --- a/test/clsocket/EchoServer.cpp +++ b/test/clsocket/EchoServer.cpp @@ -19,11 +19,15 @@ int main(int argc, char **argv) { if ((pClient = socket.Accept()) != NULL) { + int clientPort = socket.GetClientPort(); + printf("connected from %s:%d\n", socket.GetClientAddr(),clientPort); //---------------------------------------------------------------------- // Receive request from the client. //---------------------------------------------------------------------- if (pClient->Receive(MAX_PACKET)) { + char* msg = (char*) pClient->GetData(); + printf("received message [%s]\n",msg); //------------------------------------------------------------------ // Send response to client and close connection to the client. //------------------------------------------------------------------ diff --git a/test/clsocket/QueryDayTime.cpp b/test/clsocket/QueryDayTime.cpp index a853abfab..46084256d 100644 --- a/test/clsocket/QueryDayTime.cpp +++ b/test/clsocket/QueryDayTime.cpp @@ -24,10 +24,12 @@ int main(int argc, char **argv) //---------------------------------------------------------------------- // Send a requtest the server requesting the current time. //---------------------------------------------------------------------- - const char* data = "Hello!"; + char data[1024]; + sprintf(data,"%s","Hello!"); int len = strlen(data); - - if (socket.Send((const uint8 *)"HELLO\n", len)) + data[len]=0; + len++; + if (socket.Send((const uint8 *)data, len)) { //---------------------------------------------------------------------- // Receive response from the server. diff --git a/test/clsocket/premake4.lua b/test/clsocket/premake4.lua new file mode 100644 index 000000000..530cbdb90 --- /dev/null +++ b/test/clsocket/premake4.lua @@ -0,0 +1,51 @@ + + +project ("Test_clsocket_EchoServer") + + language "C++" + + kind "ConsoleApp" + + includedirs {"../../examples/ThirdPartyLibs/clsocket/src"} + + if os.is("Windows") then + defines { "WIN32" } + links {"Ws2_32","Winmm"} + end + if os.is("Linux") then + end + if os.is("MacOSX") then + end + + links {"clsocket"} + + files { + "EchoServer.cpp", + } + + + + +project ("Test_clsocket_QueryDayTime") + + language "C++" + + kind "ConsoleApp" + + includedirs {"../../examples/ThirdPartyLibs/clsocket/src"} + + if os.is("Windows") then + defines { "WIN32" } + links {"Ws2_32","Winmm"} + end + if os.is("Linux") then + end + if os.is("MacOSX") then + end + + links {"clsocket"} + + files { + "QueryDayTime.cpp", + } +