[Gambas-devel] networking 0.0.14

Benoit Minisini gambas at ...20...
Mon Nov 3 23:44:03 CET 2003


Le Lundi 3 Novembre 2003 20:31, Daniel Campos a écrit :
> Hi!
>
> Here's 0.0.14 release of "networking" component.
>
> - There's a lot of internal code reorganisation
>
> - A big part of "GB.Raise's" has been translated
>   to "GB.Post's"
>
> - ClientSocket has two new properties : "LocalPort"
>   and "LocalHost", but the old property "Port" has
>   been renamed to "RemotePort", so if you were using
>   ClientSocket, you need to update your code (sorry)
>
> - The first part of the HttpClient has been implemented.
>   It is not yet documented, but you can find in this
>   source code an example "Http_Get" to test it.
>
> By the way, does Linus Tolvalds kwnow you can create a little web
> browser with ten lines of Gambas Code? Take a look at
> Http_Get example. :)

Hi Daniel,

Good job ! I'm eager to integrate your component into the main source...

What I told you about GB.Raise() and GB.Post() is not exact.
Actually, I think you could call GB.Raise() like you did.

Calling GB.Raise() is forbidden:
- In a thread.
- In a signal handler.

Using GB.Post() instead of GB.Raise() in a watch callback is in fact not 
necessary.

With GB.Raise(), the following scenario enters an infinite loop that fills the 
stack.

Watch a file descriptor for reading ==> event loop ==> data comes on the file 
descriptor ==> call the callback ==> raise an event ==> call the gambas event 
handler ==> the event handler uses the WAIT instruction (aargh !) before 
reading the file descriptor ==> event loop ==> file descriptor has already 
data ready to be read ==> call the callback ... The callback is twice on the 
stack.

With GB.Post(), the scenario is almost the same, except that the stack is 
'less' filled.

Watch a file descriptor for reading ==> event loop ==> data comes on the file 
descriptor ==> call the callback ==> post an event and return to the event 
loop ==> raise the event ==> call the gambas event handler ==> the event 
handler uses the WAIT instruction (aargh !) before reading the file 
descriptor ==> event loop ==> file descriptor has already data ready to be 
read ==> call the callback (the callback is once on the stack) ==>

So, the user must be careful with the WAIT instruction !

Or I can prevent the WAIT instruction from raising posted events, but then the 
following code will not work anymore:

...
Socket.ConnectSocket("localhost",7)
While Socket.Status <> 7  ' while connection is not completed
        Wait (0.1)
        Print "Connecting..."
Loop
...

I think there is no real solution because of the WAIT instruction, that is 
useful after all.

Regards,

-- 
Benoit Minisini
mailto:gambas at ...1...





More information about the Devel mailing list