[Gambas-devel] Gambas Interface

Benoit Minisini gambas at ...1...
Wed Apr 28 13:41:34 CEST 2004


On Wednesday 28 April 2004 13:42, danielcampos at ...45... wrote:
> >...is sent to the parent automatically. You don't need accessing the
> > >parent yourself ?
>
>  No, I think the problem is that i've explained my problem very bad, I
> don't know why I've used the word 'parent' if I was not exatly talking
> about objects but structures. I'll try to do it better:
>
>
> I have a structure to define the socket class:
>
> typedef struct
> {
>    GB_BASE *ob;
>    GB_STREAM *stream,
>    int socket;
>    int iStatus;
>    ...
> } CSOCKET;
>
>  I all the code, I can use the 'THIS' macro to reference the current
> 'Socket' object, so I can manage its 'internal  properties', (the members
> of that structure, I mean), and I can pass that pointer to the rest of the
> functions.
>
>  However, when I receive a call-back, the parameter that I receive is just
> the value of the socket descriptor, but I don't know where the structure
> that holds this socket descriptor (the 'parent':) is placed. So, I've
> created an array with CSOCKET pointers, and socket descriptors, and each
> time I receive a callback, I find the socket descriptor in the array, so I
> can obtain the value of the CSOCKET pointer, to be able to modify the rest
> of 'properties', for instance 'iStatus'.
>
>  If I detect, for example, that connection was broken, in the 'write
> callback', I have to post an event, so I have to specify the CSOCKET
> pointer (the 'parent' of my socket descriptor)...
>
>  I hope I've explained it better, as really my first question was very
> obscure :)
>
> Regards,
>
> Daniel Campos
>

Why don't you use the fourth parameter of GB.Watch() ? It is passed to the 
callback.

Regards,

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




More information about the Devel mailing list