[Gambas-user] Socket Limitations

Benoît Minisini gambas at ...1...
Sat Jan 2 18:57:05 CET 2010


> > 2010/1/2 Benoît Minisini <gambas at ...1...>:
> >> Please provide the source code of the network communication,
> >> otherwise I can't see what you are doing exactly.
> 
> Ok, here is some code that adequately reproduces the problem, and the
> exact same code with a smaller chunk of text that does not have the
> problem.
> 
> SocketOK works.
> 
> ChokeASocket is exactly 100% the same code except that it has a 48k
> file to transmit to the remote server.
> 
> The remote server is already setup in the code so just run it. I
> recommend running SocketOK first. I have tried this with four
> independent servers and get the same result, SocketDeath.
> 
> Regards,
> 

OK, I identified the problem:

By default, Socket are in non-blocking mode (Blocking property set to False). 
So writing to it a big chunk fails. The bug is that instead of raising an 
error during the Write instruction, it fails silently.

By having a blocking socket, your program works.

So, two remarks:

You should set the Blocking property to True in the Ready event.

Maybe the Write instruction is silly: if the user wants to write a big chunk 
of bytes, we should temporarily enter blocking mode while writing. Or not?

It is not evident, because you may want to write on the socket only during its 
Write event and need to never block. The problem is you can't know how many 
bytes to send without sending them, and Gambas at the moment does not tell how 
many bytes were successfully sent to the socket in one shot.

Or maybe Socket must be blocking by default?

Some thinking is needed there...

-- 
Benoît Minisini




More information about the User mailing list