more tcp testing

This commit is contained in:
Erwin Coumans 2017-02-20 09:52:59 -08:00
parent 970de9c4d7
commit c10dfe6a80
3 changed files with 37 additions and 28 deletions

View File

@ -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.
//------------------------------------------------------------------

View File

@ -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;

View File

@ -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 {