summaryrefslogtreecommitdiff
path: root/i/simulotron/src/gs/gs_transmitter.cc
diff options
context:
space:
mode:
Diffstat (limited to 'i/simulotron/src/gs/gs_transmitter.cc')
-rw-r--r--i/simulotron/src/gs/gs_transmitter.cc4
1 files changed, 4 insertions, 0 deletions
diff --git a/i/simulotron/src/gs/gs_transmitter.cc b/i/simulotron/src/gs/gs_transmitter.cc
index 0a0fd44..e593cdb 100644
--- a/i/simulotron/src/gs/gs_transmitter.cc
+++ b/i/simulotron/src/gs/gs_transmitter.cc
@@ -28,6 +28,7 @@
#include "socket/socket_client.hh"
#include <sys/select.h>
+#include <iostream>
GSTransmitter::GSTransmitter(SocketClient & socket)
:socket_(socket)
@@ -52,6 +53,9 @@ GSTransmitter::getGS(GSMessage & gsm)
std::string strRead (socket_.read ());
strBrut_ += strRead;
}
+ // Si la chaine à moins de 4 octect, y'a pas de message
+ if (strBrut_.size() < 4)
+ return -1;
// On récupère la taille de la gs grace au 4 premier octect
size = static_cast<int> (strBrut_[0]) << 24
| static_cast<int> (strBrut_[1]) << 16