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
00027 #include <string>
00028
00029 struct sockaddr;
00030
00031 namespace qpid {
00032 namespace sys {
00033
00034 class Duration;
00035
00036 class Socket : public IOHandle
00037 {
00038 public:
00040 Socket();
00041
00043 void createTcp() const;
00044
00046 void setTimeout(const Duration& interval) const;
00047
00049 void setNonblocking() const;
00050
00051 void connect(const std::string& host, uint16_t port) const;
00052
00053 void close() const;
00054
00060 int listen(uint16_t port = 0, int backlog = 10) const;
00061
00065 std::string getSockname() const;
00066
00070 std::string getPeername() const;
00071
00076 std::string getPeerAddress() const;
00081 std::string getLocalAddress() const;
00082
00083 uint16_t getLocalPort() const;
00084 uint16_t getRemotePort() const;
00085
00090 int getError() const;
00091
00095 Socket* accept(struct sockaddr *addr, socklen_t *addrlen) const;
00096
00097
00098 int read(void *buf, size_t count) const;
00099 int write(const void *buf, size_t count) const;
00100
00101 void setTcpNoDelay(bool nodelay) const;
00102
00103 private:
00104 Socket(IOHandlePrivate*);
00105 mutable std::string connectname;
00106 };
00107
00108 }}
00109 #endif