[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: |
30 May 2002 23:42:22 +0200 |
User-agent: |
Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 |
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)
Et il faut faire quand meme attention au fait qu'on
passe de fonction read/write bloquantes a non bloquantes.
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.
Sinon, vous venez au first jeudi ? moi je pense que je
pourrai faire le deplacement.
Philippe
--
,-------------------. ,---------------,----------------------.
| Philippe Brochard | ... | address@hidden | http://hocwp.free.fr |
`------------------(_ (. .) `---------------'----------------------'
-------------------ooO--(_)--Ooo--------------------------------------