Code-style consistency improvement:
Apply clang-format-all.sh using the _clang-format file through all the cpp/.h files. make sure not to apply it to certain serialization structures, since some parser expects the * as part of the name, instead of type. This commit contains no other changes aside from adding and applying clang-format-all.sh
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
|
||||
#include "PassiveSocket.h" // Include header for active socket object definition
|
||||
#include "PassiveSocket.h" // Include header for active socket object definition
|
||||
|
||||
#define MAX_PACKET 4096
|
||||
#define MAX_PACKET 4096
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
CPassiveSocket socket;
|
||||
CActiveSocket *pClient = NULL;
|
||||
CPassiveSocket socket;
|
||||
CActiveSocket *pClient = NULL;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Initialize our socket object
|
||||
//--------------------------------------------------------------------------
|
||||
socket.Initialize();
|
||||
//--------------------------------------------------------------------------
|
||||
// Initialize our socket object
|
||||
//--------------------------------------------------------------------------
|
||||
socket.Initialize();
|
||||
|
||||
socket.Listen("localhost", 6667);
|
||||
socket.Listen("localhost", 6667);
|
||||
|
||||
while (true)
|
||||
{
|
||||
if ((pClient = socket.Accept()) != NULL)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if ((pClient = socket.Accept()) != NULL)
|
||||
{
|
||||
int clientPort = socket.GetClientPort();
|
||||
printf("connected from %s:%d\n", socket.GetClientAddr(),clientPort);
|
||||
//----------------------------------------------------------------------
|
||||
// Receive request from the client.
|
||||
//----------------------------------------------------------------------
|
||||
while (1)
|
||||
printf("connected from %s:%d\n", socket.GetClientAddr(), clientPort);
|
||||
//----------------------------------------------------------------------
|
||||
// Receive request from the client.
|
||||
//----------------------------------------------------------------------
|
||||
while (1)
|
||||
{
|
||||
//printf("try receive\n");
|
||||
bool receivedData = false;
|
||||
@@ -32,15 +32,15 @@ int main(int argc, char **argv)
|
||||
recBytes = pClient->Receive(MAX_PACKET);
|
||||
if (recBytes)
|
||||
{
|
||||
char* msg = (char*) pClient->GetData();
|
||||
msg[recBytes]=0;
|
||||
printf("received message [%s]\n",msg);
|
||||
char *msg = (char *)pClient->GetData();
|
||||
msg[recBytes] = 0;
|
||||
printf("received message [%s]\n", msg);
|
||||
//------------------------------------------------------------------
|
||||
// Send response to client and close connection to the client.
|
||||
//------------------------------------------------------------------
|
||||
pClient->Send( pClient->GetData(), pClient->GetBytesReceived() );
|
||||
pClient->Send(pClient->GetData(), pClient->GetBytesReceived());
|
||||
receivedData = true;
|
||||
if (strncmp(msg,"stop",4)==0)
|
||||
if (strncmp(msg, "stop", 4) == 0)
|
||||
{
|
||||
printf("Stop request received\n");
|
||||
break;
|
||||
@@ -50,18 +50,18 @@ int main(int argc, char **argv)
|
||||
{
|
||||
printf("Didn't receive data.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf("Disconnecting client.\n");
|
||||
pClient->Close();
|
||||
delete pClient;
|
||||
}
|
||||
}
|
||||
delete pClient;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Receive request from the client.
|
||||
//-----------------------------------------------------------------------------
|
||||
socket.Close();
|
||||
//-----------------------------------------------------------------------------
|
||||
// Receive request from the client.
|
||||
//-----------------------------------------------------------------------------
|
||||
socket.Close();
|
||||
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user