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 | c33f3d8550b9b4455ad6ca8a2327a7bd9d6f7db1 (patch) | |
| tree | bb5d68281986eb1664c227d15f303664a65d5e03 /cpp/src/qpid/sys/Socket.h | |
| parent | 76fb78a8495b6cd48c633e8b6219b29761133d82 (diff) | |
| download | qpid-python-c33f3d8550b9b4455ad6ca8a2327a7bd9d6f7db1.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/qpid@473087 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/Socket.h')
| -rw-r--r-- | cpp/src/qpid/sys/Socket.h | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/cpp/src/qpid/sys/Socket.h b/cpp/src/qpid/sys/Socket.h index 243764353e..9853d98496 100644 --- a/cpp/src/qpid/sys/Socket.h +++ b/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*/ |
