summaryrefslogtreecommitdiff
path: root/i/marvin/src/socket
diff options
context:
space:
mode:
authorhaller2006-05-07 21:39:58 +0000
committerhaller2006-05-07 21:39:58 +0000
commitc768e610aa4ec4cbd11a919e65ee984d8d71b868 (patch)
tree61db04f7f2ed58ddebc57e385eac4a4e43c9d3f3 /i/marvin/src/socket
parent5a534ef4253328eec26acfabc8d8cbcb5641b67c (diff)
* Amélioration de socket_client
* Codage du server_log en lui faisant manger des DataInput
Diffstat (limited to 'i/marvin/src/socket')
-rw-r--r--i/marvin/src/socket/socket_client.cc22
-rw-r--r--i/marvin/src/socket/socket_client.hh2
2 files changed, 12 insertions, 12 deletions
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<const uint8_t *>(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