Page 1 of 1

Increse input Buffer in WebSocket

Posted: Wed May 20, 2020 7:47 am
by Damir
how can Increse input Buffer in WebSocket
8192 -> 32350
dont work ???? unpredictible results
Sometimes OK, mostly fails

winsock.c

Code: Select all

//----------------------------------------------------------------------------//

HB_FUNC( RECV )  //  nSocket --> cResult
{
   LPBYTE buffer = ( LPBYTE ) hb_xgrab( 8192 );

   // WORD wLen = recv( hb_parni( 1 ), ( char * ) buffer, 8192, 0 ); // 8192
   WORD wLen = recv( hb_parni( 1 ), ( char * ) buffer, 32350, 0 ); // 32350

   // if( wLen < 10000 )  // socket errors = 10000 + ...
   if( wLen < 32350 )  
      hb_storvclen( ( char * ) buffer, wLen, 2 );
   else
      hb_storvclen( "", 0, 2 );

   hb_retni( wLen );
   hb_xfree( buffer );
}

//----------------------------------------------------------------------------//
 
dgorisek@inet.hr

Re: Increse input Buffer in WebSocket

Posted: Wed May 20, 2020 11:24 am
by byte-one

Code: Select all

LPBYTE buffer = ( LPBYTE ) hb_xgrab( 8192 );
should also

Code: Select all

LPBYTE buffer = ( LPBYTE ) hb_xgrab( 32350 );

Re: Increse input Buffer in WebSocket

Posted: Wed May 20, 2020 12:55 pm
by Antonio Linares
Please review the function ServeClient() here. This is the right way to do it:

https://github.com/FiveTechSoft/wsserve ... server.prg

Code: Select all

      nLen = 1

      while nLen > 0
         cBuffer := Space( 4096 )
         if ( nLen := hb_socketRecv( hSocket, @cBuffer,,, TIMEOUT ) ) > 0  
            cRequest += Left( cBuffer, nLen )
         else
            if nLen == -1 .and. hb_socketGetError() == HB_SOCKET_ERR_TIMEOUT
               nLen = 0
            endif
         endif
      end

Re: Increse input Buffer in WebSocket

Posted: Wed May 20, 2020 10:34 pm
by Damir
Thanks for quick response

I will try to implement it in my "Harbor" WebSocketServer.
Chemistry, mostly translated into "Harbor" from "Java"
https://github.com/TooTallNate/Java-Web ... tag/v1.4.0
But It Works OK. and Fast.

look at: "My first FWH app"
http://fivetechsupport.com/forums/viewt ... d&start=45

Email: dgorisek@inet.hr