From 695965a636bddfbafa0e8b8c66bfd3e7efa5d440 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@0f7e0d06-a6f9-0310-a55f-d5f984f55e4c> Date: Thu, 10 Feb 2005 23:10:52 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'START'. git-svn-id: file:///usr/local/opt/svn/repos/glagen@6 0f7e0d06-a6f9-0310-a55f-d5f984f55e4c --- .../algo_distribue/network/data/Data_exemple.hh | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 tags/START/glagen/algo_distribue/network/data/Data_exemple.hh (limited to 'tags/START/glagen/algo_distribue/network/data/Data_exemple.hh') diff --git a/tags/START/glagen/algo_distribue/network/data/Data_exemple.hh b/tags/START/glagen/algo_distribue/network/data/Data_exemple.hh new file mode 100644 index 0000000..ca1291b --- /dev/null +++ b/tags/START/glagen/algo_distribue/network/data/Data_exemple.hh @@ -0,0 +1,66 @@ +// Classe Data_exemple + +// Un exemple sur un point de coordonnees 3D + +#ifndef DATA_EXEMPLE_HH_ +# define DATA_EXEMPLE_HH_ + +#include +#include // Pour write/read + +#include + +class Data_exemple +{ +public: + Data_exemple() : _x(0), _y(0), _z(0) {}; + Data_exemple(int x, int y, int z) : _x(x), _y(y), _z(z) {}; + + void write_data(const int& fd) const + { + std::cout << "Donnees envoyes au serveur" << std::endl; + std::cout << _x << std::endl; + std::cout << _y << std::endl; + std::cout << _z << std::endl; + write(fd, &_x, sizeof(int)); + write(fd, &_y, sizeof(int)); + write(fd, &_z, sizeof(int)); + } + + void read_data(const int& fd) + { + do + { + errno = 0; + read(fd, &_x, sizeof(int)); + } + while (errno == 4); + + do + { + errno = 0; + read(fd, &_y, sizeof(int)); + } + while (errno == 4); + + do + { + errno = 0; + read(fd, &_z, sizeof(int)); + } + while (errno == 4); + + std::cout << "Reception message sur le file descriptor :" << fd + << std::endl; + std::cout << _x << std::endl; + std::cout << _y << std::endl; + std::cout << _z << std::endl; + } + +private: + int _x; + int _y; + int _z; +}; + +#endif // DATA_EXEMPLE -- cgit v1.2.3