adjusted clsocket build and test, so there is an EchoServer and QueryDayTime sending a string to the EchoServer.
This commit is contained in:
@@ -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.
|
||||
//------------------------------------------------------------------
|
||||
|
||||
@@ -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.
|
||||
|
||||
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