MCS
0.3.3-alpha7
|
Retrieve informations about network interfaces. More...
#include <mcs.hh>
Public Member Functions | |
unsigned int | count () |
Return how many network interfaces are present in the system. More... | |
unsigned int | index () |
Return the index of the actual interface. More... | |
string | ipaddress (int index=-1) |
Return the IP address of an interface. More... | |
string | name (int index=-1) |
Return the name of an interface. More... | |
NetInterface (string name="lo") | |
Constructor. More... | |
NetInterface (const NetInterface &) | |
Declared to avoid using of default copy constructor. More... | |
NetInterface & | operator= (const NetInterface &) |
Declared to avoid using of default assignment operator. More... | |
~NetInterface () | |
Destructor. More... | |
Protected Member Functions | |
int | getflags () |
bool | isup () |
int | req (int ioctl_num, struct ifreq *ifr) |
void | str_sockaddr (struct sockaddr *sa) |
void | str_sockaddr_in (struct sockaddr_in *sin) |
Protected Attributes | |
unsigned int | lindex |
vector< string > | names |
Vector containing the name of all interfaces present in the system. More... | |
Retrieve informations about network interfaces.
This class can be used to obtain informations such as the name or the IP address of a network interface. It is used by the ServerSocket class to obtain a "struct sockaddr_in" needed to create a server socket.
mcs::NetInterface::NetInterface | ( | string | name = "lo" | ) |
Constructor.
This constructor create a NetInterface objects linked to the interface named in the first parameter, so that any call to methods will return informations about this interface. If you want to know the names of the interfaces present in the system you should create the object without any parameter (deafult value for name is "lo"), then call the name() method with an index going from 0 to count().
name | Name of the interface, default is "lo" for the localhost interface (127.0.0.1). |
mcs::NetInterface::NetInterface | ( | const NetInterface & | ) |
Declared to avoid using of default copy constructor.
unsigned int mcs::NetInterface::count | ( | ) |
unsigned int mcs::NetInterface::index | ( | ) |
string mcs::NetInterface::ipaddress | ( | int | index = -1 | ) |
Return the IP address of an interface.
If no argument is given will return the address of the actual interface, otherwise will return the address of the interface with the index equal to the argument. Note that the index must be less then count().
index | Interface index, default is -1 for actual interface. |
string mcs::NetInterface::name | ( | int | index = -1 | ) |
Return the name of an interface.
If no argument is given will return the name of the actual interface, otherwise will return the name of the interface with the index equal to the argument. Note that the index must be less then count().
index | Interface index, default is -1 for actual interface. |
NetInterface& mcs::NetInterface::operator= | ( | const NetInterface & | ) |
Declared to avoid using of default assignment operator.
|
protected |
![]() |
MCS (My Customizable Server) ver. 0.3.3-alpha7
|