[Gambas-user] server socket problem

Benoît Minisini gambas at ...1...
Sun May 24 22:36:20 CEST 2009


> Hi to all!
>
> I have a problem with server socket.
>
> I made a little http server with Gambas. This server must send large
> file, so it read 1KB from the file, write it and wait. The wait is
> calculated to fit the max band chosed by the server administrator.
> So if the max band is 1KB/s the pause is 1 sec, if band is 2kb/s then
> the pause is 0.5 secs.
>
> Now, this is ok.
>
> But if the client is very slow compared with the server band, the
> server seems to freeze some second (the gui became unresponsive), then
> it work again 1 or 2 second, and again freeze.
> I tested this with: wget --limit-rate=1k localhost:65000/filename
>
> This is the code:
>
> WHILE NOT (Eof(myfile))
>           IF Seek(myfile) + dim_buf <= Lof(myfile) THEN
>             READ #myfile, b, dim_buf
>           ELSE
>             READ #myfile, b, (Lof(myfile) - Seek(myfile))
>           END IF
>
>           WRITE #LAST, b, Len(b)
>           WAIT pausa ' 1 sec = 1kb/s, 0.5 sec=2kb/s and so on.
> WEND
>
>
> Thank you for your help!
>
> Project page: http://code.google.com/p/bashare/
>

The WRITE instruction will block your program if the internal socket buffer is 
full because the reader is not fast enough to get it.

I think this is what happened.

Regards,


-- 
Benoît




More information about the User mailing list