From f1bce63c55af4208ccabbecfc1fbd0df110f8af3 Mon Sep 17 00:00:00 2001 From: fcolin Date: Thu, 1 Feb 2007 13:05:22 +0000 Subject: Utilisateur : Fcolin Date : 25/11/02 Heure : 16:15 Archivé dans $/Bus/Ivy Commentaire: (vss 18) --- Bus/Ivy/ThreadedSocket.cxx | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'Bus/Ivy/ThreadedSocket.cxx') diff --git a/Bus/Ivy/ThreadedSocket.cxx b/Bus/Ivy/ThreadedSocket.cxx index 31bcf18..42a8216 100644 --- a/Bus/Ivy/ThreadedSocket.cxx +++ b/Bus/Ivy/ThreadedSocket.cxx @@ -26,21 +26,8 @@ CThreadedSocket::CThreadedSocket() CThreadedSocket::~CThreadedSocket() { - long PreviousCount = 0; - int err; if (m_hSocket != INVALID_SOCKET) Close(); - //if ( thread ) // On fait de l'auto delete mais dans le cas de terminaison anormale l'object reste ????!!! - // delete thread; -// TRACE("CThreadedSocket waiting for thread end ...\n"); - if ( h_reader ) WaitForSingleObject( h_reader, INFINITE ); - // wake up writer - if ( h_writer ) - { - err = ReleaseSemaphore(send_count, 1, &PreviousCount); - WaitForSingleObject( h_writer, INFINITE ); - } -// TRACE("CThreadedSocket all thread ended\n"); } int CThreadedSocket::Create(UINT nSocketPort, int nSocketType, const char * lpszSocketAddress) { @@ -136,12 +123,24 @@ int CThreadedSocket::Bind(UINT nSocketPort, const char * lpszSocketAddress) void CThreadedSocket::Close() { + long PreviousCount = 0; + int err; if (m_hSocket != INVALID_SOCKET) { //ASSERT(SOCKET_ERROR != closesocket(m_hSocket)); closesocket(m_hSocket); // close silently m_hSocket = INVALID_SOCKET; - + //if ( thread ) // On fait de l'auto delete mais dans le cas de terminaison anormale l'object reste ????!!! + // delete thread; +// TRACE("CThreadedSocket waiting for thread end ...\n"); + if ( h_reader ) WaitForSingleObject( h_reader, INFINITE ); + // wake up writer + if ( h_writer ) + { + err = ReleaseSemaphore(send_count, 1, &PreviousCount); + WaitForSingleObject( h_writer, INFINITE ); + } +// TRACE("CThreadedSocket all thread ended\n"); } } int CThreadedSocket::Listen(int nConnectionBacklog) -- cgit v1.1