adjusted clsocket build and test, so there is an EchoServer and QueryDayTime sending a string to the EchoServer.
This commit is contained in:
@@ -71,10 +71,17 @@
|
|||||||
description = "Don't build Extras"
|
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
|
newoption
|
||||||
{
|
{
|
||||||
trigger = "no-enet",
|
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
|
newoption
|
||||||
@@ -271,18 +278,20 @@ end
|
|||||||
include "../examples/ThirdPartyLibs/midi"
|
include "../examples/ThirdPartyLibs/midi"
|
||||||
end
|
end
|
||||||
|
|
||||||
if not _OPTIONS["no_clsocket"] then
|
if not _OPTIONS["no-clsocket"] then
|
||||||
include "../examples/ThirdPartyLibs/clsocket"
|
|
||||||
defines {"BT_ENABLE_CLSOCKET"}
|
defines {"BT_ENABLE_CLSOCKET"}
|
||||||
|
include "../examples/ThirdPartyLibs/clsocket"
|
||||||
|
include "../test/clsocket"
|
||||||
end
|
end
|
||||||
|
|
||||||
if not _OPTIONS["no-enet"] then
|
if not _OPTIONS["no-enet"] then
|
||||||
|
defines {"BT_ENABLE_ENET"}
|
||||||
|
|
||||||
include "../examples/ThirdPartyLibs/enet"
|
include "../examples/ThirdPartyLibs/enet"
|
||||||
include "../test/enet/nat_punchthrough/client"
|
include "../test/enet/nat_punchthrough/client"
|
||||||
include "../test/enet/nat_punchthrough/server"
|
include "../test/enet/nat_punchthrough/server"
|
||||||
include "../test/enet/chat/client"
|
include "../test/enet/chat/client"
|
||||||
include "../test/enet/chat/server"
|
include "../test/enet/chat/server"
|
||||||
defines {"BT_ENABLE_ENET"}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if _OPTIONS["no-bullet3"] then
|
if _OPTIONS["no-bullet3"] then
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
|
|
||||||
includedirs {
|
includedirs {
|
||||||
".","include"
|
".","include","src"
|
||||||
}
|
}
|
||||||
files {
|
files {
|
||||||
"src/SimpleSocket.cpp",
|
"src/SimpleSocket.cpp",
|
||||||
|
|||||||
@@ -19,11 +19,15 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
if ((pClient = socket.Accept()) != NULL)
|
if ((pClient = socket.Accept()) != NULL)
|
||||||
{
|
{
|
||||||
|
int clientPort = socket.GetClientPort();
|
||||||
|
printf("connected from %s:%d\n", socket.GetClientAddr(),clientPort);
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Receive request from the client.
|
// Receive request from the client.
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
if (pClient->Receive(MAX_PACKET))
|
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.
|
// Send response to client and close connection to the client.
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|||||||
@@ -24,10 +24,12 @@ int main(int argc, char **argv)
|
|||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Send a requtest the server requesting the current time.
|
// Send a requtest the server requesting the current time.
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
const char* data = "Hello!";
|
char data[1024];
|
||||||
|
sprintf(data,"%s","Hello!");
|
||||||
int len = strlen(data);
|
int len = strlen(data);
|
||||||
|
data[len]=0;
|
||||||
if (socket.Send((const uint8 *)"HELLO\n", len))
|
len++;
|
||||||
|
if (socket.Send((const uint8 *)data, len))
|
||||||
{
|
{
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Receive response from the server.
|
// Receive response from the server.
|
||||||
|
|||||||
51
test/clsocket/premake4.lua
Normal file
51
test/clsocket/premake4.lua
Normal file
@@ -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",
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user