bool s13WXWServer::SendString (wxSocketBase *socSocket, std::string strLine)
{
    char *cBuf = new char[(strLine.size () + 1)];
    const char *cCopy = strLine.c_str ();

    for (unsigned int iIdx = 0; iIdx < (strLine.size () + 1); iIdx++)
        cBuf[iIdx] = cCopy[iIdx];

    cBuf[strLine.size ()] = '\0';

    //ArrayZero (cBuf, (strLine.size () + 1));
    //ArrayCopy (((char *)strLine.c_str ()), cBuf, (strLine.size () + 1));

    socSocket->SetNotify (wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
    socSocket->Write (cBuf, ((strLine.size () + 1) * sizeof (char)));
    socSocket->SetNotify (wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);

    delete []cBuf;
    cBuf = 0;

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (false);
    }

    return (true);
}
CServerSocket::~CServerSocket()
{
	// 접속된 소켓은 모두 닫는다.
	for(long i = 0; i < (long)m_vecpClient.size(); i++)
	{
		CloseClientSocket(i);
	}

	Close();

}
bool s13WXWServer::SendUChar (wxSocketBase *socSocket, unsigned char ucChar)
{
    socSocket->Write ((const char *)&ucChar, sizeof (unsigned char));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (false);
    }

    return (true);
}
bool s13WXWServer::SendUShort (wxSocketBase *socSocket, unsigned short usShort)
{
    socSocket->Write ((const char *)&usShort, sizeof (unsigned short));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (false);
    }

    return (true);
}
bool s13WXWServer::SendULong (wxSocketBase *socSocket, unsigned long ulLong)
{
    socSocket->Write ((const char *)&ulLong, sizeof (unsigned long));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (false);
    }

    return (true);
}
bool s13WXWServer::SendInt (wxSocketBase *socSocket, int iInt)
{
    socSocket->Write ((const char *)&iInt, sizeof (int));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (false);
    }

    return (true);
}
bool s13WXWServer::SendDouble (wxSocketBase *socSocket, double dDouble)
{
    socSocket->Write ((const char *)&dDouble, sizeof (double));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (false);
    }

    return (true);
}
bool s13WXWServer::SendFloat (wxSocketBase *socSocket, float fFloat)
{
    socSocket->Write ((const char *)&fFloat, sizeof (float));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (false);
    }

    return (true);
}
float s13WXWServer::RecvFloat (wxSocketBase *socSocket)
{
    float fFloat = 0.0f;
    socSocket->Read ((char *)&fFloat, sizeof (float));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (0.0f);
    }

    return (fFloat);
}
示例#10
0
double s13WXWServer::RecvDouble (wxSocketBase *socSocket)
{
    double dDouble = 0.0;
    socSocket->Read ((char *)&dDouble, sizeof (double));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (0.0);
    }

    return (dDouble);
}
示例#11
0
int s13WXWServer::RecvInt (wxSocketBase *socSocket)
{
    int iInt = 0;
    socSocket->Read ((char *)&iInt, sizeof (int));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (0);
    }

    return (iInt);
}
示例#12
0
unsigned char s13WXWServer::RecvUChar (wxSocketBase *socSocket)
{
    unsigned char ucChar = 0x00;
    socSocket->Read ((char *)&ucChar, sizeof (unsigned char));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (0);
    }

    return (ucChar);
}
示例#13
0
unsigned short s13WXWServer::RecvUShort (wxSocketBase *socSocket)
{
    unsigned short usShort = 0;
    socSocket->Read ((char *)&usShort, sizeof (unsigned short));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (0);
    }

    return (usShort);
}
示例#14
0
char s13WXWServer::RecvChar (wxSocketBase *socSocket)
{
    char cChar = 0x00;
    socSocket->Read ((char *)&cChar, sizeof (char));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (0);
    }

    return (cChar);
}
示例#15
0
short s13WXWServer::RecvShort (wxSocketBase *socSocket)
{
    short sShort = 0;
    socSocket->Read ((char *)&sShort, sizeof (short));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (0);
    }

    return (sShort);
}
示例#16
0
unsigned long s13WXWServer::RecvULong (wxSocketBase *socSocket)
{
    unsigned long ulLong = 0;
    socSocket->Read ((char *)&ulLong, sizeof (unsigned long));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (0);
    }

    return (ulLong);
}
示例#17
0
long s13WXWServer::RecvLong (wxSocketBase *socSocket)
{
    long lLong = 0;
    socSocket->Read ((char *)&lLong, sizeof (long));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (0);
    }

    return (lLong);
}
示例#18
0
unsigned int s13WXWServer::RecvUInt (wxSocketBase *socSocket)
{
    unsigned int uiInt = 0;
    socSocket->Read ((char *)&uiInt, sizeof (unsigned int));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (0);
    }

    return (uiInt);
}
示例#19
0
char *s13WXWServer::RecvString (wxSocketBase *socSocket, int iLength)
{
    char *cString = new char [(iLength + 1)];
    //ArraySet (cString, (iLength + 1), '\0');

    for (unsigned int iIdx = 0; iIdx < (iLength + 1); iIdx++)
        cString[iIdx] = '\0';

    socSocket->Read (cString, (iLength + 1));

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return (0);
    }

    return (cString);
}
示例#20
0
std::string s13WXWServer::RecvString (wxSocketBase *socSocket)
{
    char *cString = new char [(defNET_MAX_TEXT_SIZE + 1)];
    //ArraySet (cString, (defNET_MAX_TEXT_SIZE + 1), '\0');

    for (unsigned int iIdx = 0; iIdx < (defNET_MAX_TEXT_SIZE + 1); iIdx++)
        cString[iIdx] = '\0';

    socSocket->Read (cString, defNET_MAX_TEXT_SIZE);

    std::string strString = cString;
    delete []cString;
    cString = 0;

    if (socSocket->Error () == true)
    {
        CloseClientSocket (socSocket);

        return ("");
    }

    return (strString);
}
示例#21
0
BOOL CIocpServer::Stop()
{
	if(!CheckStoping())
		return FALSE;

	WaitForAcceptThreadEnd();
	WaitForWorkerThreadEnd();

	CloseClientSocket();
	CloseListenSocket();

	FireServerShutdown();

	ReleaseFreeSocket();
	ReleaseFreeBuffer();

	CloseCompletePort();

	Reset();

	m_enState = SS_STOPED;

	return TRUE;
}
/*
 * Application entry point.
 */
int main(int argc, char* argv[])
{
	char *ip = NULL;
	char *port = NULL;
	int iResult = 0;

	system("cls");

	// Check input arguments for IP and PORT and open client socket if required
	if (argc != 3)
	{
		printf("Usage: %s <IP> <PORT>\n", argv[0]);
		printf("EyeX data will not be streamed\n");
	}
	else
	{
		ip = argv[1];
		port = argv[2];
		printf("Trying connection with %s : %s\n", ip, port);
		clientSocket = OpenClientSocket(ip, port);
		if (clientSocket == INVALID_SOCKET)
		{
			printf("Error at connection with %s : %s\n", ip, port);
			printf("EyeX data will not be streamed\n");
		}
		else
		{
			streaming = TRUE;
		}
	}
	Sleep(2000);

	TX_CONTEXTHANDLE hContext = TX_EMPTY_HANDLE;
	TX_TICKET hConnectionStateChangedTicket = TX_INVALID_TICKET;
	TX_TICKET hEventHandlerTicket = TX_INVALID_TICKET;
	BOOL success;

	// initialize and enable the context that is our link to the EyeX Engine.
	success = txInitializeEyeX(TX_EYEXCOMPONENTOVERRIDEFLAG_NONE, NULL, NULL, NULL, NULL) == TX_RESULT_OK;
	success &= txCreateContext(&hContext, TX_FALSE) == TX_RESULT_OK;
	success &= InitializeGlobalInteractorSnapshot(hContext);
	success &= txRegisterConnectionStateChangedHandler(hContext, &hConnectionStateChangedTicket, OnEngineConnectionStateChanged, NULL) == TX_RESULT_OK;
	success &= txRegisterEventHandler(hContext, &hEventHandlerTicket, HandleEvent, NULL) == TX_RESULT_OK;
	success &= txEnableConnection(hContext) == TX_RESULT_OK;

	// let the events flow until a key is pressed.
	if (success) {
		printf("Initialization was successful.\n");
	} else {
		printf("Initialization failed.\n");
	}
	printf("Press X to exit...\n");
	_getch();
	printf("Exiting.\n");

	// disable and delete the context.
	txDisableConnection(hContext);
	txReleaseObject(&g_hGlobalInteractorSnapshot);
	txShutdownContext(hContext, TX_CLEANUPTIMEOUT_DEFAULT, TX_FALSE);
	txReleaseContext(&hContext);

	if (streaming)
	{
		SendFloatClientSocket(clientSocket, -1);
		CloseClientSocket(clientSocket);
	}

	Beep(300, 750);
	return 0;
}