Browse Source

Added send() function for ReadableString.

release/0.19
JustinAJ 10 years ago
parent
commit
deabb45c21
  1. 7
      Jupiter/Socket.cpp
  2. 13
      Jupiter/Socket.h

7
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); 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) 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) int Jupiter::Socket::sendTo(const addrinfo *info, const char *data, size_t datalen)

13
Jupiter/Socket.h

@ -385,14 +385,25 @@ namespace Jupiter
*/ */
virtual int send(const char *data, size_t datalen); 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. * @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. * @param String containing the null-terminated data to send.
* @return Number of bytes sent on success, SOCKET_ERROR (-1) otherwise. * @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. * 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. * @brief Sends data across the socket.

Loading…
Cancel
Save