From c768e610aa4ec4cbd11a919e65ee984d8d71b868 Mon Sep 17 00:00:00 2001 From: haller Date: Sun, 7 May 2006 21:39:58 +0000 Subject: * Amélioration de socket_client * Codage du server_log en lui faisant manger des DataInput --- i/marvin/src/socket/socket_client.cc | 22 ++++++++++------------ i/marvin/src/socket/socket_client.hh | 2 ++ 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'i/marvin/src/socket') diff --git a/i/marvin/src/socket/socket_client.cc b/i/marvin/src/socket/socket_client.cc index 9dd19fa..951ea6a 100644 --- a/i/marvin/src/socket/socket_client.cc +++ b/i/marvin/src/socket/socket_client.cc @@ -95,19 +95,17 @@ SocketClient::read (std::string & strReaded, bool bloquant) void SocketClient::write (const std::string & str) { - char buffer[BUFFER_SIZE]; - unsigned int pos = 0; - int retval = 0; + write(reinterpret_cast(str.data()), str.size()); +} - while (str.size () != pos) - { - int size = str.size () - pos < BUFFER_SIZE - 1 ? str.size () - pos:BUFFER_SIZE - 1; - str.copy (buffer, size, pos); - pos += size; - retval = ::write (socket_, buffer, size); - if (retval < 0) - throw errno_exception ("SocketClient: erreur d'écriture (write()) ", errno); - } +void +SocketClient::write (const uint8_t * buffer, unsigned size) +{ + int retval; + + retval = ::write (socket_, buffer, size); + if (retval < 0) + throw errno_exception ("SocketClient: erreur d'écriture (write()) ", errno); } //int diff --git a/i/marvin/src/socket/socket_client.hh b/i/marvin/src/socket/socket_client.hh index 066f5fd..d17a983 100644 --- a/i/marvin/src/socket/socket_client.hh +++ b/i/marvin/src/socket/socket_client.hh @@ -55,6 +55,8 @@ class SocketClient :public NonCopyable bool read (std::string & strReaded, bool bloquant); /// écrit dans le socket void write (const std::string & str); + /// écrit dans le socket + void write (const uint8_t * buffer, unsigned size); }; #endif //socket_client_hh -- cgit v1.2.3