summaryrefslogtreecommitdiff
path: root/2005/i/robert/src/socket/test_server.cc
diff options
context:
space:
mode:
authordufourj2005-05-01 15:37:34 +0000
committerdufourj2005-05-01 15:37:34 +0000
commitaecaf24c22013482de84ac6567249bec5ae7c78e (patch)
tree1aeb3d2ced48f6cdda6d39665fdb4062d83189da /2005/i/robert/src/socket/test_server.cc
parent714e86c96ff93fb78d4340cb607c12927091417b (diff)
DataBuffer :
Rajout du type de données Socket : Non-bloquant
Diffstat (limited to '2005/i/robert/src/socket/test_server.cc')
-rw-r--r--2005/i/robert/src/socket/test_server.cc32
1 files changed, 25 insertions, 7 deletions
diff --git a/2005/i/robert/src/socket/test_server.cc b/2005/i/robert/src/socket/test_server.cc
index 479dbca..40224a7 100644
--- a/2005/i/robert/src/socket/test_server.cc
+++ b/2005/i/robert/src/socket/test_server.cc
@@ -26,6 +26,8 @@
#include "socket_text.hh"
#include "data/data_input_file.hh"
#include "data/data_buffer.hh"
+#include "image/raw_reader.hh"
+#include "image/image.hh"
#include <iostream>
#include <fstream>
@@ -42,17 +44,33 @@ main (int argc, char **argv)
ServerSocket ss (atoi (argv[1]));
Address a;
SocketText st (ss, a);
+ st.nonblock ();
// DataBuffer de reception
DataBuffer db;
// Reception des données
+ while (!st.recv ());
st >> db;
- std::cout << ">> Reçu " << db.size () << " bits." << std::endl;
- // Récupération des données du DataBuffer
- std::vector <char> v (db.size ());
- db.read ((uint8_t*) &v[0], db.size ());
- // Ecriture dans le fichier
- std::ofstream file (argv[2]);
- file.write (&v[0], v.size ());
+ if (db.type () != DataBuffer::Image)
+ throw std::runtime_error ("Echec de la transmission");
+ RawReader reader (db, 360, 296, Image::rgb);
+ Image img (360, 296, Image::rgb);
+ img.read (reader);
+ std::ofstream file (argv[2]);
+ file.write ((char*) img.getBuf (), img.getBufSize ());
+
+// // Récupération des données du DataBuffer
+// std::vector <char> v (db.size ());
+// db.read ((uint8_t*) &v[0], db.size ());
+// // Ecriture dans le fichier
+// std::ofstream file (argv[2]);
+// file.write (&v[0], v.size ());
+// DataBuffer db1;
+// // Reception des données
+// while (!st.recv ());
+// st >> db1;
+// std::cout << ">> Reçu " << db1.size () << " bits." << std::endl;
+// if (db1.type () != DataBuffer::Image)
+// throw std::runtime_error ("Echec de la transmission");
}
catch (const std::runtime_error &r)
{