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;
	}
	void Run () {
		LOGDEBUG (TEXT ("Creating server pipe"));
		CNamedPipe *poServer = m_bRead ? CNamedPipe::ServerRead (m_pszPipeName, false) : CNamedPipe::ServerWrite (m_pszPipeName, false);
		if (poServer) {
			if (m_bAccept) {
repeatOperation:
				LOGDEBUG (TEXT ("Accepting client connection"));
				m_poPipe = poServer->Accept (TIMEOUT_PIPE);
				if (m_poPipe) {
					if (m_nReadWriteOperations) {
						int rw = _ReadAndWrite (m_poPipe, m_nReadWriteOperations, m_bThrottle, TEXT ("Server"));
						if (rw == 0) {
							LOGDEBUG (TEXT ("Didn't read or write"));
							m_nFailure = FAIL_NO_READWRITE;
						} else if (rw < abs (m_nReadWriteOperations)) {
							LOGDEBUG (TEXT ("Partial read or write - ") << rw << TEXT (", expected ") << abs (m_nReadWriteOperations));
							m_nFailure = FAIL_PARTIAL_READWRITE;
						}
					} else {
						LOGDEBUG (TEXT ("Sleeping"));
						CThread::Sleep (TIMEOUT_HANG);
					}
					LOGDEBUG (TEXT ("Deleting client connection object"));
					delete m_poPipe;
					m_poPipe = NULL;
					if (m_bRepeat) {
						LOGDEBUG (TEXT ("Repeating operation"));
						m_bRepeat = false;
						goto repeatOperation;
					}
				} else {
					LOGDEBUG (TEXT ("Didn't accept client"));
					m_nFailure = FAIL_NO_ACCEPT;
				}
			} else {
				LOGDEBUG (TEXT ("Sleeping"));
				CThread::Sleep (TIMEOUT_HANG);
			}
			LOGDEBUG (TEXT ("Deleting server object"));
			delete poServer;
		} else {
			LOGDEBUG (TEXT ("Couldn't create pipe"));
			m_nFailure = FAIL_NO_CREATE;
		}
	}
	void Run () {
		LOGDEBUG (TEXT ("Sleeping"));
		CThread::Sleep (TIMEOUT_HANG / 2);
		CNamedPipe *poPipe = *m_ppoPipe;
		ASSERT (poPipe);
		if (m_lLazyClose) {
			LOGDEBUG (TEXT ("Lazy close"));
			poPipe->LazyClose (m_lLazyClose);
			if (m_bCancel) {
				LOGDEBUG (TEXT ("Sleeping"));
				CThread::Sleep (m_lLazyClose / 2);
				LOGDEBUG (TEXT ("Cancelling lazy close"));
				poPipe->CancelLazyClose ();
			}
		} else {
			LOGDEBUG (TEXT ("Close"));
			poPipe->Close ();
		}
	}