source:
orxonox.OLD/branches/proxy/src/lib/network/ip.h
@
9316
Last change on this file since 9316 was 9311, checked in by bensch, 18 years ago | |
---|---|
File size: 1.1 KB |
Rev | Line | |
---|---|---|
[7899] | 1 | |
2 | /*! | |
[9304] | 3 | * @file ip.h |
[7899] | 4 | * |
[9306] | 5 | * @brief the ip class is used to transform strings to ip's and backwards |
6 | * it can also be used to | |
7 | * | |
[7899] | 8 | */ |
9 | ||
[9304] | 10 | #ifndef __IP_H__ |
11 | #define __IP_H__ | |
[7899] | 12 | |
[9304] | 13 | #include <string> |
14 | ||
15 | #include "netdefs.h" | |
16 | ||
17 | ||
[7899] | 18 | //! A class to handle time itself |
[9304] | 19 | class IP |
[7899] | 20 | { |
[9304] | 21 | public: |
[9311] | 22 | /// CONSTRUCTORS |
[9304] | 23 | IP(); |
[9310] | 24 | IP(const std::string& ip, int port = -1, bool resolve = true); |
[9306] | 25 | IP(int ip, int port); |
26 | IP(const IPaddress& ip); | |
27 | IP(const IP& ip); | |
[7899] | 28 | |
[9311] | 29 | /// OPERATORS |
[9306] | 30 | const IP& operator=(const IP& ip); |
31 | bool operator==(const IP& ip); | |
[7899] | 32 | |
[9311] | 33 | /// RETRIEAL |
[9310] | 34 | /** @returns the IP */ |
[9305] | 35 | int ip() const { return this->_ip; }; |
[9310] | 36 | /** @returns the Port */ |
[9305] | 37 | short port() const { return this->_port; }; |
[9304] | 38 | |
[9306] | 39 | int ipPart(unsigned int part) const; |
40 | std::string ipString() const; | |
[9304] | 41 | |
42 | public: | |
[9311] | 43 | |
44 | /// SETUP | |
[9310] | 45 | static IP stringToIP(const std::string& ip, int port = -1, bool resolve = true); |
[9306] | 46 | |
47 | ||
[9305] | 48 | static std::string ipToString(const IPaddress& ipaddr); |
[9307] | 49 | static std::string ipToString(int ip, int port = -1); |
[9304] | 50 | |
51 | private: | |
[9306] | 52 | int _ip; //!< The IP in int form. |
53 | short _port; //!< The Port number of the IP | |
[9304] | 54 | |
[7899] | 55 | }; |
56 | ||
[9304] | 57 | #endif /* __IP_H__ */ |
Note: See TracBrowser
for help on using the repository browser.