2011-05-16 17:38 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbmisc/udpds.prg
    ! replaced previous workaround with one that doesn't need 
      any delay in hb_UDPDS_Stop()
This commit is contained in:
Viktor Szakats
2011-05-16 15:40:17 +00:00
parent 66fdcc3bbb
commit a8981174ad
2 changed files with 17 additions and 8 deletions

View File

@@ -16,6 +16,11 @@
The license applies to all entries newer than 2009-04-28.
*/
2011-05-16 17:38 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbmisc/udpds.prg
! replaced previous workaround with one that doesn't need
any delay in hb_UDPDS_Stop()
2011-05-16 09:33 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* include/harbour.hbx
* src/vm/runner.c

View File

@@ -23,8 +23,6 @@
#include "hbsocket.ch"
STATIC s_lRunThread
/* Client */
FUNCTION hb_UDPDS_Find( nPort, cName )
@@ -59,7 +57,6 @@ FUNCTION hb_UDPDS_Start( nPort, cName, cVersion )
IF ! Empty( hSocket := hb_socketOpen( , HB_SOCKET_PT_DGRAM ) )
IF hb_socketBind( hSocket, { HB_SOCKET_AF_INET, "0.0.0.0", nPort } )
s_lRunThread := .T.
hb_threadDetach( hb_threadStart( @UDPDS(), hSocket, cName, cVersion ) )
RETURN hSocket
ENDIF
@@ -70,8 +67,6 @@ FUNCTION hb_UDPDS_Start( nPort, cName, cVersion )
PROCEDURE hb_UDPDS_Stop( hSocket )
s_lRunThread := .F.
hb_idleSleep( 0.1 )
hb_socketClose( hSocket )
RETURN
@@ -80,9 +75,16 @@ STATIC PROCEDURE UDPDS( hSocket, cName, cVersion )
LOCAL cBuffer, nLen, aAddr
DO WHILE s_lRunThread
DO WHILE .T.
cBuffer := Space( 2000 )
nLen := hb_socketRecvFrom( hSocket, @cBuffer, , , @aAddr, 1000 )
BEGIN SEQUENCE WITH {| oErr | Break( oErr ) }
nLen := hb_socketRecvFrom( hSocket, @cBuffer, , , @aAddr, 1000 )
RECOVER
nLen := NIL
END SEQUENCE
IF nLen == NIL
EXIT
ENDIF
IF nLen == -1
IF hb_socketGetError() != HB_SOCKET_ERR_TIMEOUT
RETURN
@@ -94,7 +96,9 @@ STATIC PROCEDURE UDPDS( hSocket, cName, cVersion )
* Server response: ACK, ServerName, NUL, Version
*/
IF Left( cBuffer, nLen ) == Chr( 5 ) + cName + Chr( 0 )
hb_socketSendTo( hSocket, Chr( 6 ) + cName + Chr( 0 ) + iif( cVersion == NIL, "", cVersion ), , , aAddr )
BEGIN SEQUENCE WITH {| oErr | Break( oErr ) }
hb_socketSendTo( hSocket, Chr( 6 ) + cName + Chr( 0 ) + iif( cVersion == NIL, "", cVersion ), , , aAddr )
END SEQUENCE
ENDIF
ENDIF
ENDDO