diff options
Diffstat (limited to 'Bus')
-rw-r--r-- | Bus/Ivy/ThreadedSocket.cxx | 27 |
1 files changed, 13 insertions, 14 deletions
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)
|