Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/proxy/src/lib/network/ip.h @ 9321

Last change on this file since 9321 was 9321, checked in by bensch, 19 years ago

more elaborate IP

File size: 1.4 KB
RevLine 
[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]19class IP
[7899]20{
[9304]21  public:
[9311]22    /// CONSTRUCTORS
[9304]23    IP();
[9321]24    IP(int ip, int port);
25    IP(const std::string& ip, bool resolve = true);
[9310]26    IP(const std::string& ip, int port = -1, bool resolve = true);
[9306]27    IP(const IPaddress& ip);
28    IP(const IP& ip);
[7899]29
[9311]30    /// OPERATORS
[9306]31    const IP& operator=(const IP& ip);
32    bool operator==(const IP& ip);
[7899]33
[9321]34    /// RETRIVEAL
[9310]35    /** @returns the IP */
[9305]36    int ip() const { return this->_ip; };
[9310]37    /** @returns the Port */
[9305]38    short port() const { return this->_port; };
[9304]39
[9306]40    int ipPart(unsigned int part) const;
41    std::string ipString() const;
[9304]42
[9321]43    void debug() const;
44
[9304]45  public:
[9311]46    /// SETUP
[9310]47    static IP stringToIP(const std::string& ip, int port = -1, bool resolve = true);
[9306]48
[9305]49    static std::string ipToString(const IPaddress& ipaddr);
[9307]50    static std::string ipToString(int ip, int port = -1);
[9304]51
[9321]52
53    static void setDefaultPort(short defaultPort);
54    static short defaultPort(short defaultPort) { return IP::_defaultPort; };
55
[9304]56  private:
[9321]57    int           _ip;           //!< The IP in int form.
58    short         _port;         //!< The Port number of the IP
[9304]59
[9321]60
61    static short  _defaultPort;  //!< Default Port
[7899]62};
63
[9304]64#endif /* __IP_H__ */
Note: See TracBrowser for help on using the repository browser.