summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--i/simulotron/src/gs/test_gs.cc27
-rw-r--r--i/simulotron/src/socket/socket_client.cc5
2 files changed, 27 insertions, 5 deletions
diff --git a/i/simulotron/src/gs/test_gs.cc b/i/simulotron/src/gs/test_gs.cc
index 9aef410..7054354 100644
--- a/i/simulotron/src/gs/test_gs.cc
+++ b/i/simulotron/src/gs/test_gs.cc
@@ -108,6 +108,7 @@ void * testGSServ(void * CaSertARien)
<< std::endl;
return (void *)1;
}
+ std::cout << "String OK" << std::endl;
// Un char
if (gst.getGS(gsm) != 0)
throw std::runtime_error ("CHIER!! Reception mal passé");
@@ -120,6 +121,7 @@ void * testGSServ(void * CaSertARien)
<< std::endl;
return (void *)1;
}
+ std::cout << "Char OK" << std::endl;
// Un short
if (gst.getGS(gsm) != 0)
throw std::runtime_error ("CHIER!! Reception mal passé");
@@ -132,6 +134,7 @@ void * testGSServ(void * CaSertARien)
<< std::endl;
return (void *)1;
}
+ std::cout << "Short OK" << std::endl;
// Un int positif
if (gst.getGS(gsm) != 0)
throw std::runtime_error ("CHIER!! Reception mal passé");
@@ -144,6 +147,7 @@ void * testGSServ(void * CaSertARien)
<< std::endl;
return (void *)1;
}
+ std::cout << "int positif OK" << std::endl;
// Un int negatif
if (gst.getGS(gsm) != 0)
throw std::runtime_error ("CHIER!! Reception mal passé");
@@ -156,18 +160,20 @@ void * testGSServ(void * CaSertARien)
<< std::endl;
return (void *)1;
}
+ std::cout << "int negatif OK" << std::endl;
// Un Long
if (gst.getGS(gsm) != 0)
throw std::runtime_error ("CHIER!! Reception mal passé");
gsm.readGS(&l2, sizeof(char));
if ( l1 != l2)
{
- std::cout << "CHIER int positif altéré\n"
+ std::cout << "CHIER long altéré\n"
<< "Message d'origine: " << l1 << "\n"
<< "Message d'arrivé: " << l2
<< std::endl;
return (void *)1;
}
+ std::cout << "int positif OK" << std::endl;
// Un gros message
if (gst.getGS(gsm) != 0)
throw std::runtime_error ("CHIER!! Reception mal passé");
@@ -198,8 +204,9 @@ void * testGSServ(void * CaSertARien)
<< std::endl;
return (void *)1;
}
+ std::cout << "Gros message OK" << std::endl;
}
- catch(errno_exception & chier)
+ catch(std::exception & chier)
{
std::cout << "CHIER !! Une exception a été lancé coté serveur!!" << std::endl;
std::cout << chier.what() << std::endl;
@@ -220,17 +227,31 @@ void * testGSClient(void * CaSertARien)
GSTransmitter gst(sockClient);
GSMessage g1,g2,g3,g4,g5,g6,g7;
g1.writeGS(strDepart.c_str(), strDepart.size());
+ gst.putGS(g1);
g2.writeGS(&s1, sizeof(short));
+ gst.putGS(g2);
g3.writeGS(&i1, sizeof(int));
+ gst.putGS(g3);
g4.writeGS(&i3, sizeof(int));
+ gst.putGS(g4);
g5.writeGS(&l1, sizeof(long));
+ gst.putGS(g5);
g6.writeGS(&s1, sizeof(short));
g6.writeGS(&l1, sizeof(long));
g6.writeGS(&i3, sizeof(int));
+ gst.putGS(g6);
+ std::cout << "Et pouf" << std::endl;
+
+ /*//tv
+ timeval tv;
+ tv.tv_sec = 20;
+ tv.tv_usec = 0;
+ select(1,NULL,NULL,NULL,&tv);
+ */
}
- catch(errno_exception & chier)
+ catch(std::exception & chier)
{
std::cout << "CHIER !! Une exception a été lancé coté client!!" << std::endl;
std::cout << chier.what() << std::endl;
diff --git a/i/simulotron/src/socket/socket_client.cc b/i/simulotron/src/socket/socket_client.cc
index 1224389..9099089 100644
--- a/i/simulotron/src/socket/socket_client.cc
+++ b/i/simulotron/src/socket/socket_client.cc
@@ -72,8 +72,9 @@ SocketClient::read (void)
charReaded = ::read (socket_, buffer, BUFFER_SIZE - 1);
if (charReaded < 0)
throw errno_exception ("SocketClient: problème de lecture", errno);
- buffer[charReaded] = 0;
- str += buffer;
+ //buffer[charReaded] = 0;
+ //str += buffer;
+ str.append(buffer, charReaded);
}while (charReaded == BUFFER_SIZE - 1);
return str;
}