00001 #ifndef _sys_Socket_h
00002 #define _sys_Socket_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "IOHandle.h"
00026 #include "qpid/sys/IntegerTypes.h"
00027
00028 #include <string>
00029
00030 struct sockaddr;
00031
00032 namespace qpid {
00033 namespace sys {
00034
00035 class Duration;
00036
00037 class Socket : public IOHandle
00038 {
00039 public:
00041 Socket();
00042
00044 void createTcp() const;
00045
00047 void setTimeout(const Duration& interval) const;
00048
00050 void setNonblocking() const;
00051
00052 void connect(const std::string& host, uint16_t port) const;
00053
00054 void close() const;
00055
00061 int listen(uint16_t port = 0, int backlog = 10) const;
00062
00066 std::string getSockname() const;
00067
00071 std::string getPeername() const;
00072
00077 std::string getPeerAddress() const;
00082 std::string getLocalAddress() const;
00083
00084 uint16_t getLocalPort() const;
00085 uint16_t getRemotePort() const;
00086
00091 int getError() const;
00092
00096 Socket* accept(struct sockaddr *addr, socklen_t *addrlen) const;
00097
00098
00099 int read(void *buf, size_t count) const;
00100 int write(const void *buf, size_t count) const;
00101
00102 void setTcpNoDelay(bool nodelay) const;
00103
00104 private:
00105 Socket(IOHandlePrivate*);
00106 mutable std::string connectname;
00107 };
00108
00109 }}
00110 #endif