void Run () { int nAttempt = 0; CNamedPipe *poPipe; do { if (nAttempt) { Sleep (TIMEOUT / 10); } poPipe = CNamedPipe::ClientWrite (m_pszPipeName); } while (!poPipe && (GetLastError () == ENOENT) && (++nAttempt < 10)); if (poPipe) { LOGDEBUG (TEXT ("Client connected")); ClientConnect cc; memset (&cc, 0, sizeof (cc)); cc._userName = TEST_USERNAME; cc._CPPToJavaPipe = TEST_CPP2JAVA; cc._JavaToCPPPipe = TEST_JAVA2CPP; cc._languageID = TEST_LANGUAGE; cc._debug = TEST_DEBUG; FudgeMsg msg; ASSERT (ClientConnect_toFudgeMsg (&cc, &msg) == FUDGE_OK); FudgeMsgEnvelope env; ASSERT (FudgeMsgEnvelope_create (&env, 0, 0, 0, msg) == FUDGE_OK); fudge_byte *ptrBuffer; fudge_i32 cbBuffer; ASSERT (FudgeCodec_encodeMsg (env, &ptrBuffer, &cbBuffer) == FUDGE_OK); FudgeMsgEnvelope_release (env); FudgeMsg_release (msg); ASSERT (poPipe->Write (ptrBuffer, cbBuffer, TIMEOUT) == cbBuffer); delete ptrBuffer; } else { LOGWARN (TEXT ("Couldn't open client pipe, error ") << GetLastError ()); } }
void Run () { CSettings settings; ASSERT (settings.GetConnectionPipe ()); LOGDEBUG (TEXT ("Connecting to ") << settings.GetConnectionPipe ()); CNamedPipe *poPipe = CNamedPipe::ClientWrite (settings.GetConnectionPipe ()); ASSERT (poPipe); LOGDEBUG (TEXT ("Client connected")); ClientConnect cc; memset (&cc, 0, sizeof (cc)); cc._userName = TEST_USERNAME; cc._CPPToJavaPipe = TEST_CPP2JAVA; cc._JavaToCPPPipe = TEST_JAVA2CPP; cc._languageID = TEST_LANGUAGE; #ifdef _DEBUG cc._debug = FUDGE_TRUE; #endif /* ifdef _DEBUG */ FudgeMsg msg; ASSERT (ClientConnect_toFudgeMsg (&cc, &msg) == FUDGE_OK); FudgeMsgEnvelope env; ASSERT (FudgeMsgEnvelope_create (&env, 0, 0, 0, msg) == FUDGE_OK); fudge_byte *ptrBuffer; fudge_i32 cbBuffer; ASSERT (FudgeCodec_encodeMsg (env, &ptrBuffer, &cbBuffer) == FUDGE_OK); FudgeMsgEnvelope_release (env); FudgeMsg_release (msg); LOGDEBUG (TEXT ("Writing connection packet")); ASSERT (poPipe->Write (ptrBuffer, cbBuffer, TIMEOUT_CONNECT) == (size_t)cbBuffer); LOGDEBUG (TEXT ("Connection packet written")); delete ptrBuffer; LOGDEBUG (TEXT ("Disconnecting")); delete poPipe; }