more tcp testing
This commit is contained in:
@@ -32,7 +32,7 @@ int main(int argc, char **argv)
|
|||||||
if (pClient->Receive(MAX_PACKET))
|
if (pClient->Receive(MAX_PACKET))
|
||||||
{
|
{
|
||||||
char* msg = (char*) pClient->GetData();
|
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.
|
// Send response to client and close connection to the client.
|
||||||
//------------------------------------------------------------------
|
//------------------------------------------------------------------
|
||||||
|
|||||||
@@ -19,15 +19,18 @@ int main(int argc, char **argv)
|
|||||||
// and received.
|
// and received.
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// if (socket.Open("time-C.timefreq.bldrdoc.gov", 13))
|
// if (socket.Open("time-C.timefreq.bldrdoc.gov", 13))
|
||||||
if (socket.Open("localhost", 6667))
|
if (socket.Open("192.168.86.196", 6667))
|
||||||
|
{
|
||||||
|
for (int i=0;i<100;i++)
|
||||||
{
|
{
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Send a requtest the server requesting the current time.
|
// Send a requtest the server requesting the current time.
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
char data[1024];
|
char data[1024];
|
||||||
sprintf(data,"%s","Hello!");
|
sprintf(data,"%s %d","Hello",i);
|
||||||
int len = strlen(data);
|
int len = strlen(data);
|
||||||
data[len]=0;
|
data[len]=0;
|
||||||
|
printf("Sending [%s]\n",data);
|
||||||
len++;
|
len++;
|
||||||
if (socket.Send((const uint8 *)data, len))
|
if (socket.Send((const uint8 *)data, len))
|
||||||
{
|
{
|
||||||
@@ -39,7 +42,9 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
uint8* data = socket.GetData();
|
uint8* data = socket.GetData();
|
||||||
memcpy(&time, data, len);
|
memcpy(&time, data, len);
|
||||||
printf("%s\n", time);
|
printf("Received: [%s]\n", time);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
@@ -47,7 +52,6 @@ int main(int argc, char **argv)
|
|||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
socket.Close();
|
socket.Close();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -13,8 +13,10 @@ project ("Test_clsocket_EchoServer")
|
|||||||
links {"Ws2_32","Winmm"}
|
links {"Ws2_32","Winmm"}
|
||||||
end
|
end
|
||||||
if os.is("Linux") then
|
if os.is("Linux") then
|
||||||
|
defines {"_LINUX"}
|
||||||
end
|
end
|
||||||
if os.is("MacOSX") then
|
if os.is("MacOSX") then
|
||||||
|
defines {"_DARWIN"}
|
||||||
end
|
end
|
||||||
|
|
||||||
links {"clsocket"}
|
links {"clsocket"}
|
||||||
@@ -38,9 +40,12 @@ project ("Test_clsocket_QueryDayTime")
|
|||||||
defines { "WIN32" }
|
defines { "WIN32" }
|
||||||
links {"Ws2_32","Winmm"}
|
links {"Ws2_32","Winmm"}
|
||||||
end
|
end
|
||||||
|
|
||||||
if os.is("Linux") then
|
if os.is("Linux") then
|
||||||
|
defines {"_LINUX"}
|
||||||
end
|
end
|
||||||
if os.is("MacOSX") then
|
if os.is("MacOSX") then
|
||||||
|
defines {"_DARWIN"}
|
||||||
end
|
end
|
||||||
|
|
||||||
links {"clsocket"}
|
links {"clsocket"}
|
||||||
|
|||||||
Reference in New Issue
Block a user