I forgot about one thing.
I'm attaching simple .prg code which can be linked with MT HVM
which shows the speed overhead inside current hb_inetRecvLine().
Please check the speed difference when you executed compiled
program without any parameter and with some non empty parameter.
In the second version simple .prg function prg_recvline() is used
with hb_inetRecv() to emulate read ahead buffer.
BTW I'm interesting in Windows results for above code so if possible
please I would like to ask desktop windows and WinCE/WinMobile users
to send here "total client time" for above test code executed in both
modes.
best regards,
Przemek
#define N_LOOP 10
static s_nPort := 2345
static s_cHost := "127.0.0.1"
static s_lStop := .f.
proc main( xPar )
local sock, th
sock := hb_inetServer( s_nPort )
hb_inetTimeOut( sock, 100 )
if hb_inetErrorCode( sock ) != 0
? "bind/listen error"
hb_inetClose( sock )
sock := NIL
else
th := hb_threadStart( @srv(), sock )
hb_threadJoin( hb_threadStart( @cli(), !empty( xPar ) ) )
? "client stopped"
? "server socked closed:", hb_inetClose( sock )
s_lStop := .t.
hb_threadJoin( th )
endif
?
return
proc srv( sock )
local conn, n
n := 0
while .t.
conn := hb_inetAccept( sock )
if conn == NIL
if s_lStop
? "server stopped"
exit
endif
else
hb_inetSendAll( conn, "This is connection: " + hb_ntos( ++n ) + ;
hb_inetCRLF() )
hb_inetSendAll( conn, repl( repl( "=", 260 ) + ;
hb_inetCRLF(), 1000 ) )
hb_inetSendAll( conn, "EOT" + hb_inetCRLF() )
hb_inetClose( conn )
conn := NIL
endif
enddo
return
proc cli( lPrgRecv )
local sock, cLine, nLine, nTime, nTot, n, buf
nTot := seconds()
for n := 1 to N_LOOP
sock := hb_inetConnectIP( s_cHost, s_nPort )
if hb_inetErrorCode( sock ) != 0
? "connect error"
else
buf := ""
nLine := 0
nTime := seconds()
while .t.
if lPrgRecv
cLine := prg_recvline( sock, @buf )
else
cLine := hb_inetRecvLine( sock )
endif
if valtype( cLine ) != "C"
? "recv error at line:", hb_ntos( nLine )
wait
exit
endif
++nLine
if cLine == "EOT"
nTime := seconds() - nTime
? "connection closed, lines:", hb_ntos( nLine )
? "time:", hb_ntos( nTime ), "sec."
exit
elseif nLine == 1
? "First line:", cLine
endif
enddo
endif
hb_inetClose( sock )
sock := NIL
next
nTot := seconds() - nTot
? "=============================="
? "total client time:", hb_ntos( nTot ), "sec." + ;
iif( lPrgRecv, "*", "^" )
? "=============================="
return
static func prg_recvline( sock, buf )
local cEOL := hb_inetCRLF(), s, n
while .t.
n := at( cEOL, buf )
if n != 0
exit
endif
if s == NIL
s := space( 100 )
endif
n := hb_inetRecv( sock, @s )
if n <= 0
return NIL
endif
buf += left( s, n )
enddo
s := left( buf, n - 1 )
buf := substr( buf, n + len( cEOL ) )
return s
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour