[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Maitretarot-devel-fr] new protocol
From: |
philippe brochard |
Subject: |
Re: [Maitretarot-devel-fr] new protocol |
Date: |
01 Jun 2002 00:18:19 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
"address@hidden"<address@hidden> writes:
> > Yves Mettier <address@hidden> writes:
> >
> > > Salut!
> > >
> > > J'ai ajoute un composant a libmaitretarot.
> > > Ce truc est en fait un thread qui lit les donnees
> venant du reseau
> > > (client ou serveur, peu importe) et qui les stoque
> dans des zones, une
> > > par canal.
> > >
> > > L'existant est preserve, donc n'ayez aucune crainte a
> avoir a
> > > telecharger le CVS de libmaitretarot.
> > >
> > > Je n'ai pas encore eu l'occasion de tester avec
> maitretarot, mais je
> > > vais faire ca des que j'ai le temps.
> > >
> > > Voici un extrait du nouveau code:
> > >
> > > /*
> > > * HOW DOES NET_CONSUMER WORK?
> > > *
> > > * First, init gthreads with g_thread_init(NULL);
> > > *
> > > * Second, init net_consumer with:
> > > * channels_set = libmt_channels_set_new(sock_id);
> > > * where sock_id is the socket identifier from
> which the data are
> > > read.
> > > *
> > > * Then, except for the channel 0 (enabled by
> default), enable
> > > * the channels you want to read with:
> > > * libmt_channels_set_enable
> (channels_set,channel_id);
> > > * where channels_set is what
> libmt_channels_set_new returned
> > > * and where channel_id is the channel identifier.
> > > *
> > > * To read/write data on a channel:
> > > * libmt_channels_set_read(channels_set,
> channel_id, buffer, len);
> > > * libmt_channels_set_write(channels_set,
> channel_id, buffer, len);
> > > * where channels_set is what
> libmt_channels_set_new returned
> > > * and where channel_id is the channel identifier
> > > * and where buffer is a char* buffer where the
> data will be
> > > read/written
> > > * and where len is the max length of data to put
> in the buffer.
> > > *
> > > * To free the channels_set:
> > > * libmt_channels_set_free(channels_set);
> > > *
> > > * Misc functions:
> > > * libmt_channels_set_is_socket_working
> (channels_set);
> > > * returns TRUE if the socket is working (not
> closed) and FALSE
> > > otherwise
> > > *
> > > * libmt_channels_set_available_data_length
> (channels_set,
> > > channel_id);
> > > * returns the length available for reading on
> the channel
> > > channel_id.
> > > */
> > >
> > >
> > >
> > > Bref un peu d'initialisation (3 ou 4 lignes au debut
> du prog), puis
> > > juste a remplacer les read_data par des
> channel_set_read. Et remplacer
> > > l'identificateur de socket par le numero de canal.
> > > Apres, on peut lire quand on veut sur les canaux, et
> ce n'est pas
> > > bloquant ni pour le serveur ni pour le client.
> > >
> > > Dites-moi ce que vous en pensez.
> > >
> > Super, ca a l'air tres bien :)
> >
> > Les fonctions supplementaires ont l'air d'etre utiles
> > (en particulier libmt_channels_set_is_socket_working)
>
> Oui.
> Celle-la en particulier n'est pas finie: elle est loin
> d'etre blindee. Mais son API est deja figee je pense.
>
Ok, on peut quand meme commencer a s'en servir, meme si
c'est pas trop robuste.
>
> > Et il faut faire quand meme attention au fait qu'on
> > passe de fonction read/write bloquantes a non
> bloquantes.
>
> A priori, avec ca, c'est non bloquant, puisque c'est un
> thread separe qui remplit les buffers.
> Par contre, je viens de me rendre compte d'un enorme bug.
> J'avais dans l'esprit qu'il n'y avait pas vraiment de
> probleme de concurrence, mais y'en a quand meme. Donc
> pour l'instant, ca peut marcher, mais faut pas stresser
> la bete. Y'a juste un mutex a rajouter, mais faut que je
> le fasse.
>
Ok, on va pas brusquer la bestiole alors ;-)
> >
> > Bon, je test tout ca des que je peut, mais pour
> l'instant,
> > je suis en plein conseil de classes + correction des
> derniers
> > devoir... D'ici 1 semaine, j'aurai un peu plus de temps.
>
> Oui, la ml etait plus calme. Au point que le we dernier,
> j'etais pas motive pour faire avancer maitretarot.
> Mais j'ai fait avancer le truc quand meme hier ;-)
>
Normalement, je peut m'y mettre demain -> j'essai de finir
le client :)
> > Sinon, vous venez au first jeudi ? moi je pense que je
> > pourrai faire le deplacement.
>
> Moi, j'y viens. Entre 19h45 et 20h30, plutot 20h, comme
> d'habitude
>
Ok alors on se vois Jeudi :)
Philippe
--
,-------------------. ,---------------,----------------------.
| Philippe Brochard | ... | address@hidden | http://hocwp.free.fr |
`------------------(_ (. .) `---------------'----------------------'
-------------------ooO--(_)--Ooo--------------------------------------