Re: Threads vs Processes

new topic     » goto parent     » topic index » view thread      » older message » newer message

Mario,

At this point, I'm using Simple Sockets Lib by jbrown as this was 
quicker for me
to get going. I think switching to the wxEuphoria socket functions and 
setting up
socket response functions will help handle connection freezes (and maybe 
give
the GUI time to to redraw the window, etc). I'll be trying this in the 
next couple of
day, work permitting.  I'm not sure that this would allow me to have 
simultaneous
downloads, though.

Thanks for your help. In the next few days, I will be trying the 
wxEuphoria socket
functions again and certainly use your advice.

Thank-you,
Bruce Douglas

Mario Steele wrote:
> If I am not mistaken, your creating your wxSocketClient, with the
> wxSOCKET_WAITALL flag implaced.  I would suggest that you use the 
> wxSOCKET_NOWAIT flag.  This will allow you to receive Asynchronous data,
> without blocking the GUI.  This ofcourse means, that you must detect, and
> buffer data, so that way you don't get any corruption in streamed data.
> 
> It is often suggestable to use builtin features of the library, before
> breaking down, and using other methods in which to get your intention across
> the program.
> 
> Something like this would be satisfactory:
> 
> }}}
<eucode>
> sequence buff
> 
> procedure parseInfo()
>      -- do your error detection here
>      -- If there is more data to be retrived,
>      -- then wait for it to be retrived,
>      -- otherwise, if you have all the data
>      -- do your parsing of it, saving, or whatever
>      -- and pass it along to what ever needs it.
> end procedure
> 
> procedure on_socket_email(atom this, atom event_type, atom id, atom event)
>      seqence dat
>      event_type = get_socket_event(event)
>      if event = wxSOCKET_INPUT then
>           dat = socket_read( socket_from_event(event) )
>           if not equal({},dat) then
>               buff &= dat
>           end if
>           if not equal({},buff) then
>               parseInfo()
>           end if
>      end if
> end procedure
> set_event_handler(your_form, client_id, wxEVT_SOCKET,
> routine_id("main_socket_event"))
> </eucode>
{{{

> 
> This should allow you to parse all the information, without having to rely
> on using sub-proccesses in order to stop the Blocking calls when you do
> a socket_read() event.
> 
> Mario Steele
> http://enchantedblade.trilake.net
> Attaining World Dominiation, one byte at a time...

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu