diff options
author | Stephen D. Huston <shuston@apache.org> | 2011-10-21 14:42:12 +0000 |
---|---|---|
committer | Stephen D. Huston <shuston@apache.org> | 2011-10-21 14:42:12 +0000 |
commit | f83677056891e436bf5ba99e79240df2a44528cd (patch) | |
tree | 625bfd644b948e89105630759cf6decb0435354d /cpp/src/qpid/sys/Socket.h | |
parent | ebfd9ff053b04ab379acfc0fefedee5a31b6d8a5 (diff) | |
download | qpid-python-QPID-2519.tar.gz |
Merged out from trunkQPID-2519
git-svn-id: https://svn.apache.org/repos/asf/qpid/branches/QPID-2519@1187375 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/Socket.h')
-rw-r--r-- | cpp/src/qpid/sys/Socket.h | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/cpp/src/qpid/sys/Socket.h b/cpp/src/qpid/sys/Socket.h index 7d50afc59f..defec4879c 100644 --- a/cpp/src/qpid/sys/Socket.h +++ b/cpp/src/qpid/sys/Socket.h @@ -33,21 +33,21 @@ namespace sys { class Duration; class SocketAddress; -class Socket : public IOHandle +class QPID_COMMON_CLASS_EXTERN Socket : public IOHandle { public: /** Create a socket wrapper for descriptor. */ QPID_COMMON_EXTERN Socket(); - /** Set timeout for read and write */ - void setTimeout(const Duration& interval) const; + /** Create a new Socket which is the same address family as this one */ + QPID_COMMON_EXTERN Socket* createSameTypeSocket() const; /** Set socket non blocking */ void setNonblocking() const; QPID_COMMON_EXTERN void setTcpNoDelay() const; - QPID_COMMON_EXTERN void connect(const std::string& host, uint16_t port) const; + QPID_COMMON_EXTERN void connect(const std::string& host, const std::string& port) const; QPID_COMMON_EXTERN void connect(const SocketAddress&) const; QPID_COMMON_EXTERN void close() const; @@ -57,19 +57,9 @@ public: *@param backlog maximum number of pending connections. *@return The bound port. */ - QPID_COMMON_EXTERN int listen(uint16_t port = 0, int backlog = 10) const; + QPID_COMMON_EXTERN int listen(const std::string& host = "", const std::string& port = "0", int backlog = 10) const; QPID_COMMON_EXTERN int listen(const SocketAddress&, int backlog = 10) const; - /** Returns the "socket name" ie the address bound to - * the near end of the socket - */ - QPID_COMMON_EXTERN std::string getSockname() const; - - /** Returns the "peer name" ie the address bound to - * the remote end of the socket - */ - std::string getPeername() const; - /** * Returns an address (host and port) for the remote end of the * socket @@ -84,16 +74,13 @@ public: /** * Returns the full address of the connection: local and remote host and port. */ - QPID_COMMON_EXTERN std::string getFullAddress() const { return getLocalAddress()+"-"+getPeerAddress(); } - - QPID_COMMON_EXTERN uint16_t getLocalPort() const; - uint16_t getRemotePort() const; + QPID_COMMON_INLINE_EXTERN std::string getFullAddress() const { return getLocalAddress()+"-"+getPeerAddress(); } /** * Returns the error code stored in the socket. This may be used * to determine the result of a non-blocking connect. */ - int getError() const; + QPID_COMMON_EXTERN int getError() const; /** Accept a connection from a socket that is already listening * and has an incoming connection @@ -108,8 +95,13 @@ private: /** Create socket */ void createSocket(const SocketAddress&) const; +public: + /** Construct socket with existing handle */ Socket(IOHandlePrivate*); - mutable std::string connectname; + +protected: + mutable std::string localname; + mutable std::string peername; mutable bool nonblocking; mutable bool nodelay; }; |