From c10dfe6a80d000db38f4e66a8bddabc751550e18 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Mon, 20 Feb 2017 09:52:59 -0800 Subject: [PATCH] more tcp testing --- test/clsocket/EchoServer.cpp | 2 +- test/clsocket/QueryDayTime.cpp | 50 ++++++++++++++++++---------------- test/clsocket/premake4.lua | 13 ++++++--- 3 files changed, 37 insertions(+), 28 deletions(-) diff --git a/test/clsocket/EchoServer.cpp b/test/clsocket/EchoServer.cpp index b5a3a0e21..74c03ac7c 100644 --- a/test/clsocket/EchoServer.cpp +++ b/test/clsocket/EchoServer.cpp @@ -32,7 +32,7 @@ int main(int argc, char **argv) if (pClient->Receive(MAX_PACKET)) { char* msg = (char*) pClient->GetData(); - //printf("received message [%s]\n",msg); + 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 cb7381a64..2211f37ce 100644 --- a/test/clsocket/QueryDayTime.cpp +++ b/test/clsocket/QueryDayTime.cpp @@ -19,35 +19,39 @@ int main(int argc, char **argv) // and received. //-------------------------------------------------------------------------- // if (socket.Open("time-C.timefreq.bldrdoc.gov", 13)) - if (socket.Open("localhost", 6667)) - { - //---------------------------------------------------------------------- - // Send a requtest the server requesting the current time. - //---------------------------------------------------------------------- - char data[1024]; - sprintf(data,"%s","Hello!"); - int len = strlen(data); - data[len]=0; - len++; - if (socket.Send((const uint8 *)data, len)) - { - //---------------------------------------------------------------------- - // Receive response from the server. - //---------------------------------------------------------------------- - int rec = socket.Receive(len); - if (rec) - { - uint8* data = socket.GetData(); - memcpy(&time, data, len); - printf("%s\n", time); - } + if (socket.Open("192.168.86.196", 6667)) + { + for (int i=0;i<100;i++) + { + //---------------------------------------------------------------------- + // Send a requtest the server requesting the current time. + //---------------------------------------------------------------------- + char data[1024]; + sprintf(data,"%s %d","Hello",i); + int len = strlen(data); + data[len]=0; + printf("Sending [%s]\n",data); + len++; + if (socket.Send((const uint8 *)data, len)) + { + //---------------------------------------------------------------------- + // Receive response from the server. + //---------------------------------------------------------------------- + int rec = socket.Receive(len); + if (rec) + { + uint8* data = socket.GetData(); + memcpy(&time, data, len); + printf("Received: [%s]\n", time); + } + } + } //---------------------------------------------------------------------- // Close the connection. //---------------------------------------------------------------------- socket.Close(); } - } return 1; diff --git a/test/clsocket/premake4.lua b/test/clsocket/premake4.lua index 530cbdb90..4c5b742cf 100644 --- a/test/clsocket/premake4.lua +++ b/test/clsocket/premake4.lua @@ -13,8 +13,10 @@ project ("Test_clsocket_EchoServer") links {"Ws2_32","Winmm"} end if os.is("Linux") then + defines {"_LINUX"} end if os.is("MacOSX") then + defines {"_DARWIN"} end links {"clsocket"} @@ -38,11 +40,14 @@ project ("Test_clsocket_QueryDayTime") defines { "WIN32" } links {"Ws2_32","Winmm"} end + if os.is("Linux") then - end - if os.is("MacOSX") then - end - + defines {"_LINUX"} + end + if os.is("MacOSX") then + defines {"_DARWIN"} + end + links {"clsocket"} files {