00001 #ifndef _ots_Socket_h_
00002 #define _ots_Socket_h_
00003
00004 #include <netinet/in.h>
00005 #include <sys/types.h>
00006 #include <string>
00007
00008 namespace ots
00009 {
00010 class Socket
00011 {
00012 public:
00013 Socket(const std::string& IPAddress, unsigned int port = 0);
00014 virtual ~Socket(void);
00015
00016 virtual void initialize(
00017 unsigned int socketReceiveBufferSize = defaultSocketReceiveSize_);
00018 const struct sockaddr_in& getSocketAddress(void);
00019 const std::string& getIPAddress() { return IPAddress_; }
00020 uint16_t getPort();
00021
00022 protected:
00023 enum
00024 {
00025 maxSocketSize_ = 65536,
00026 defaultSocketReceiveSize_ = 0x10000
00027 };
00028
00029 Socket(void);
00030 struct sockaddr_in socketAddress_;
00031 int socketNumber_;
00032
00033
00034 protected:
00035 enum
00036 {
00037 FirstSocketPort = 10000,
00038 LastSocketPort = 15000
00039 };
00040 std::string IPAddress_;
00041 unsigned int requestedPort_;
00042 };
00043
00044 }
00045
00046 #endif