Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 9335 was 9334, checked in by patrick, 18 years ago

work of the day in one commit:D

  • switched whole network framework to ip sturcture
  • extended ip structrue a little bit
  • reimplemented the disconnection/reconnection algorithm
  • synchronizeable ip bug discovered and solved
File size: 1.6 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
[7899]7 */
8
[9304]9#ifndef __IP_H__
10#define __IP_H__
[7899]11
[9323]12#include "netdefs.h"
[9304]13#include <string>
14
15
16
[7899]17//! A class to handle time itself
[9304]18class IP
[7899]19{
[9304]20  public:
[9311]21    /// CONSTRUCTORS
[9304]22    IP();
[9321]23    IP(int ip, int port);
24    IP(const std::string& ip, bool resolve = true);
[9310]25    IP(const std::string& ip, int port = -1, bool resolve = true);
[9306]26    IP(const IPaddress& ip);
27    IP(const IP& ip);
[7899]28
[9311]29    /// OPERATORS
[9306]30    const IP& operator=(const IP& ip);
[9334]31    const IP& operator=(const IPaddress& ip);
[9306]32    bool operator==(const IP& ip);
[9334]33    bool operator!=(const IP& up);
[7899]34
[9321]35    /// RETRIVEAL
[9310]36    /** @returns the IP */
[9305]37    int ip() const { return this->_ip; };
[9310]38    /** @returns the Port */
[9305]39    short port() const { return this->_port; };
[9334]40    inline IPaddress getSDLNotation() { IPaddress sdlIP; sdlIP.host = this->_ip; sdlIP.port = this->_port; return sdlIP; }
[9304]41
[9306]42    int ipPart(unsigned int part) const;
43    std::string ipString() const;
[9304]44
[9321]45    void debug() const;
46
[9304]47  public:
[9311]48    /// SETUP
[9310]49    static IP stringToIP(const std::string& ip, int port = -1, bool resolve = true);
[9306]50
[9305]51    static std::string ipToString(const IPaddress& ipaddr);
[9307]52    static std::string ipToString(int ip, int port = -1);
[9304]53
[9321]54    static void setDefaultPort(short defaultPort);
55    static short defaultPort(short defaultPort) { return IP::_defaultPort; };
56
[9304]57  private:
[9321]58    int           _ip;           //!< The IP in int form.
59    short         _port;         //!< The Port number of the IP
[9304]60
[9321]61    static short  _defaultPort;  //!< Default Port
[7899]62};
63
[9304]64#endif /* __IP_H__ */
Note: See TracBrowser for help on using the repository browser.