diff options
author | Alan Conway <aconway@apache.org> | 2006-11-09 21:55:34 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2006-11-09 21:55:34 +0000 |
commit | 402ac40145f2d35f9f9bfd34d499336faeb65c2e (patch) | |
tree | 49084b4dcb4ba2a1b7c846dc90e997ac6582656f /qpid/cpp/src/qpid/sys/Socket.h | |
parent | 75e9bad6c3eb3a7bb207a10ec6719e859170396b (diff) | |
download | qpid-python-402ac40145f2d35f9f9bfd34d499336faeb65c2e.tar.gz |
Added POSIX equivalents to APR classes used by clients, inlined trivial calls.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@473087 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/qpid/sys/Socket.h')
-rw-r--r-- | qpid/cpp/src/qpid/sys/Socket.h | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/qpid/cpp/src/qpid/sys/Socket.h b/qpid/cpp/src/qpid/sys/Socket.h index 243764353e..9853d98496 100644 --- a/qpid/cpp/src/qpid/sys/Socket.h +++ b/qpid/cpp/src/qpid/sys/Socket.h @@ -19,9 +19,47 @@ * */ -#include <qpid/sys/platform.h> -#include QPID_PLATFORM_H(Socket.h) +#include <string> +#ifdef USE_APR +# include <apr-1/apr_network_io.h> +#endif + +namespace qpid { +namespace sys { + +class Socket +{ + public: + Socket(); + + /** Set timeout for read and write */ + void setTimeout(long msecs); + + void connect(const std::string& host, int port); + + void close(); + + enum { SOCKET_TIMEOUT=-2, SOCKET_EOF=-3 } ErrorCode; + + /** Returns bytes sent or an ErrorCode value < 0. */ + ssize_t send(const char* data, size_t size); + + /** + * Returns bytes received, an ErrorCode value < 0 or 0 + * if the connection closed in an orderly manner. + */ + ssize_t recv(char* data, size_t size); + + private: +#ifdef USE_APR + apr_socket_t* socket; +#else + int socket; +#endif +}; + +}} #endif /*!_sys_Socket_h*/ |