add method to read port number of address
Stefan Schuermans

Stefan Schuermans commited on 2011-12-27 21:01:37
Showing 3 changed files, with 12 additions and 0 deletions.

... ...
@@ -24,6 +24,9 @@ public:
24 24
   /// return address family
25 25
   virtual int getFamily() const = 0;
26 26
 
27
+  /// return port (use this function only if absolutely necessary)
28
+  virtual int getPort() const = 0;
29
+
27 30
   /**
28 31
    * @brief parse from string format
29 32
    * @param[in] str string format
... ...
@@ -86,6 +86,12 @@ int Udp4Addr::getFamily() const
86 86
   return AF_INET;
87 87
 }
88 88
 
89
+/// return port (use this function only if absolutely necessary)
90
+int Udp4Addr::getPort() const
91
+{
92
+  return ntohs(m_addr.sin_port);
93
+}
94
+
89 95
 /**
90 96
  * @brief parse from string format
91 97
  * @param[in] str string format
... ...
@@ -40,6 +40,9 @@ public:
40 40
   /// return address family
41 41
   virtual int getFamily() const;
42 42
 
43
+  /// return port (use this function only if absolutely necessary)
44
+  virtual int getPort() const;
45
+
43 46
   /**
44 47
    * @brief parse from string format
45 48
    * @param[in] str string format
46 49