Пример #1
0
static int s_sockexClose( PHB_SOCKEX pSock, HB_BOOL fClose )
{
   PHB_SOCKEX_BF pBF = HB_BFSOCK_GET( pSock );
   int iResult = 0;

   if( pBF )
   {
      if( pBF->sock )
         s_sockexFlush( pSock, HB_MAX( 15000, pSock->iAutoFlush ), HB_TRUE );

      if( pBF->sock )
      {
         if( pSock->fShutDown )
            pBF->sock->fShutDown = HB_TRUE;
         if( pSock->iAutoFlush != 0 && pBF->sock->iAutoFlush == 0 )
            pBF->sock->iAutoFlush = pSock->iAutoFlush;
         iResult = hb_sockexClose( pBF->sock, fClose );
      }
      memset( pBF, 0, sizeof( *pBF ) );
      hb_xfree( pBF );
   }
   /* call hb_sockexRawClear() with fClose = HB_FALSE because
      hb_sockexClose() already closed real socket */
   hb_sockexRawClear( pSock, HB_FALSE );
   hb_xfree( pSock );

   return iResult;
}
Пример #2
0
static int s_sockexClose( PHB_SOCKEX pSock, HB_BOOL fClose )
{
   PHB_SOCKEX_Z pZ = HB_ZSOCK_GET( pSock );
   int iResult = 0;

   if( pZ )
   {
      if( pZ->sock )
         s_sockexFlush( pSock, HB_MAX( 15000, pSock->iAutoFlush ), HB_TRUE );

      if( pZ->fDecompressIn )
         inflateEnd( &pZ->z_read );
      if( pZ->rdbuf )
         hb_xfree( pZ->rdbuf );
      if( pZ->fCompressOut )
         deflateEnd( &pZ->z_write );
      if( pZ->wrbuf )
         hb_xfree( pZ->wrbuf );

      if( pZ->sock )
      {
         if( pSock->fShutDown )
            pZ->sock->fShutDown = HB_TRUE;
         if( pSock->iAutoFlush != 0 && pZ->sock->iAutoFlush == 0 )
            pZ->sock->iAutoFlush = pSock->iAutoFlush;
         iResult = hb_sockexClose( pZ->sock, fClose );
      }

      hb_xfree( pZ );
   }
   /* call hb_sockexRawClear() with fClose = HB_FALSE because
      hb_sockexClose() already closed real socket */
   hb_sockexRawClear( pSock, HB_FALSE );
   hb_xfree( pSock );

   return iResult;
}