maitretarot-devel-fr
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Maitretarot-devel-fr] new protocol


From: Yves Mettier
Subject: [Maitretarot-devel-fr] new protocol
Date: Thu, 30 May 2002 20:52:23 +0200

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.

Yves
-- 
- Homepage - http://ymettier.free.fr                   -
- GPG key  - http://ymettier.free.fr/gpg.txt           -
- MyAM     - http://www.freesoftware.fsf.org/myam      -
- GTKtalog - http://www.freesoftware.fsf.org/gtktalog  -




reply via email to

[Prev in Thread] Current Thread [Next in Thread]