On Thu, 30 Jul 2009, Francesco Saverio Giudice wrote:

Hi,

> it's very strange because I did everytime a clean rebuild and I did also 
> this morning before I wrote the mail. Now I did a new one and the result is 
> correct (apart from few errors in my prgs I have corrected, paths etc that 
> I will upload to SVN ASAP) and similar in both versions.
> The only difference is the ajax test that in inet version works on every 
> call instead in custom socket version it didn't (I have to push button more 
> times and generally I get a correct return on 3rd-4th time)
> Sorry for wrong info, but I did a full rebuild this morning. believe me.

No problem. Good that I know that current code is working as before so
I can commit next modifications. I looked at httpsrv code and as I can
see only one thing will have to be updated for modified hbinet.c code:
in uhttpd.prg function readRequest() which uses hb_InetRecvLine().
As I can see it uses different stop condition when USE_HB_INET
is defined. I do not know if it's intentional or not anyhow if you
want to use the same stop condition in both versions then it's enough
to change USE_HB_INET code to:

   cRequest := ""
   DO WHILE .T.
      cRequest += hb_InetRecvLine( hSocket, @nLen )
      IF nLen <= 0
         /* maybe we should force -1 as the only one error in new code? */
         IF nLen < -1
            nLen := -1
         ENDIF
         EXIT
      ENDIF
      cRequest += CR_LF
      IF nLen == Len( CR_LF ) .AND. Len( cRequest ) > Len( CR_LF )
         EXIT
      ENDIF
   ENDDO

it will work like:

   cRequest := ""
   nLen     := 1
   DO WHILE AT( CR_LF + CR_LF, cRequest ) == 0 .AND. nLen > 0
      nLen := socket_recv( hSocket, @cBuf )
      cRequest += cBuf
   ENDDO

with the exception that it never reads any data after CR_LF + CR_LF so
it cannot be lost.

BTW why did you use different stop condtions in current readRequest()
    code instead of exact replication of above socket_*() code, i.e:

      cRequest := ""
      nLen     := 1
      cBuf     := Space( 4096 )
      DO WHILE AT( CR_LF + CR_LF, cRequest ) == 0 .AND. nLen > 0
         nLen := hb_InetRecv( hSocket, @cBuf )
         cRequest += Left( cBuf, nLen )
      ENDDO

   ???

best regards,
Przemek
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to