Increse input Buffer in WebSocket

Increse input Buffer in WebSocket

Postby Damir » Wed May 20, 2020 7:47 am

how can Increse input Buffer in WebSocket
8192 -> 32350
dont work ???? unpredictible results
Sometimes OK, mostly fails

winsock.c

Code: Select all  Expand view  RUN

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

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
Damir
 
Posts: 4
Joined: Thu May 24, 2018 8:23 pm
Location: Osor

Re: Increse input Buffer in WebSocket

Postby byte-one » Wed May 20, 2020 11:24 am

Code: Select all  Expand view  RUN
LPBYTE buffer = ( LPBYTE ) hb_xgrab( 8192 );

should also
Code: Select all  Expand view  RUN
LPBYTE buffer = ( LPBYTE ) hb_xgrab( 32350 );
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria

Re: Increse input Buffer in WebSocket

Postby Antonio Linares » Wed May 20, 2020 12:55 pm

Please review the function ServeClient() here. This is the right way to do it:

https://github.com/FiveTechSoft/wsserver/blob/master/wsserver.prg

Code: Select all  Expand view  RUN
     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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Increse input Buffer in WebSocket

Postby Damir » Wed May 20, 2020 10:34 pm

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-WebSocket/releases/tag/v1.4.0
But It Works OK. and Fast.

look at: "My first FWH app"
http://fivetechsupport.com/forums/viewtopic.php?f=17&t=24170&sid=5fbd852ab319a64c3fbbe66690f96c5d&start=45

Email: dgorisek@inet.hr
Damir
 
Posts: 4
Joined: Thu May 24, 2018 8:23 pm
Location: Osor


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 70 guests