00001 #ifndef _ots_Socket_h_
00002 #define _ots_Socket_h_
00003
00004 #include <sys/types.h>
00005 #include <netinet/in.h>
00006 #include <string>
00007
00008 namespace ots
00009 {
00010
00011 class Socket
00012 {
00013 public:
00014 Socket(const std::string &IPAddress, unsigned int port=0);
00015 virtual ~Socket(void);
00016
00017 virtual void initialize(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{maxSocketSize_ = 65536, defaultSocketReceiveSize_ = 0x10000};
00024
00025 Socket(void);
00026 struct sockaddr_in socketAddress_;
00027 int socketNumber_;
00028
00029
00030 private:
00031 enum{FirstSocketPort=10000,LastSocketPort=15000};
00032 std::string IPAddress_;
00033 unsigned int requestedPort_;
00034 };
00035
00036 }
00037
00038 #endif