From deabb45c217a194429797390a4e426efc73fd330 Mon Sep 17 00:00:00 2001 From: JustinAJ Date: Tue, 3 Jun 2014 03:25:21 -0400 Subject: [PATCH] Added send() function for ReadableString. --- Jupiter/Socket.cpp | 7 ++++++- Jupiter/Socket.h | 13 ++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Jupiter/Socket.cpp b/Jupiter/Socket.cpp index bb1ed07..cbfcd97 100644 --- a/Jupiter/Socket.cpp +++ b/Jupiter/Socket.cpp @@ -431,9 +431,14 @@ int Jupiter::Socket::send(const char *data, size_t datalen) return ::send(Jupiter::Socket::data_->rawSock, data, datalen, 0); } +int Jupiter::Socket::send(const Jupiter::ReadableString &str) +{ + return this->send(str.ptr(), str.size()); +} + int Jupiter::Socket::send(const char *msg) { - return Jupiter::Socket::send(msg, strlen(msg)); + return this->send(msg, strlen(msg)); } int Jupiter::Socket::sendTo(const addrinfo *info, const char *data, size_t datalen) diff --git a/Jupiter/Socket.h b/Jupiter/Socket.h index 81732e8..fb8ecad 100644 --- a/Jupiter/Socket.h +++ b/Jupiter/Socket.h @@ -385,14 +385,25 @@ namespace Jupiter */ virtual int send(const char *data, size_t datalen); + /** + * @brief Sends a string of data across the socket. + * Note: Internally, this just calls send(str.ptr(), str.size()). + * + * @param String containing the data to send. + * @return Number of bytes sent on success, SOCKET_ERROR (-1) otherwise. + * Note: Any returned value less than or equal to 0 should be treated as an error. + */ + int send(const Jupiter::ReadableString &str); + /** * @brief Sends a null-terminated string of data across the socket. + * Note: Internally, this just calls send(msg, strlen(msg)). * * @param String containing the null-terminated data to send. * @return Number of bytes sent on success, SOCKET_ERROR (-1) otherwise. * Note: Any returned value less than or equal to 0 should be treated as an error. */ - virtual int send(const char *msg); + int send(const char *msg); /** * @brief Sends data across the socket.