#include <server.h>
Public Member Functions | |
cUPnPServer () | |
virtual | ~cUPnPServer () |
void | enable (bool enabled) |
bool | start (void) |
bool | restart (void) |
void | stop (void) |
bool | autoDetectSettings (void) |
sockaddr_in * | getServerAddress (void) |
const char * | getInterface (void) const |
bool | setServerPort (unsigned short port) |
bool | setInterface (const char *Interface) |
bool | setAddress (const char *Address) |
bool | setAutoDetection (bool enable) |
bool | isEnabled (void) const |
bool | isRunning (void) const |
bool | isAutoDetectionEnabled () |
Friends | |
class | cPluginUpnp |
This is the core of the UPnP server. This handles all the components which are needed for a UPnP media server. Incoming messages are passed through it and it determines what to do.
cUPnPServer::cUPnPServer | ( | ) |
Constructor
This will create a new server and initializes the main functionalities The server has to be started manually by invoking cUPnPServer::start().
cUPnPServer::~cUPnPServer | ( | ) | [virtual] |
Destructor
This will destroy the server object. Open ports and connections will be closed.
bool cUPnPServer::autoDetectSettings | ( | void | ) |
Automatically detect settings
This will automatically detect the network settings if the autodetection is turned on.
true
, if autoDetection was successfulfalse
, otherwise void cUPnPServer::enable | ( | bool | enabled | ) |
Enable the server
This switch indicates if the server is startable or not
If it is set to false, any invocation of start() will do nothing.
enabled | if true , the server will be enabled. If false it is disabled. |
const char* cUPnPServer::getInterface | ( | void | ) | const [inline] |
Get the interface the server listens to
sockaddr_in * cUPnPServer::getServerAddress | ( | void | ) |
Get the server address
Returns a server address structure including IP address and port
bool cUPnPServer::isAutoDetectionEnabled | ( | ) | [inline] |
Is auto detection enabled or not
Returns true or false if auto detection is enabled or not
true
, if autodetection is enabledfalse
, otherwise bool cUPnPServer::isEnabled | ( | void | ) | const [inline] |
Checks if the server is enabled
This indicates if the server is currently enabled.
true
, if the server is enabledfalse
, otherwise bool cUPnPServer::isRunning | ( | void | ) | const [inline] |
Checks if the server is running
If the server is enabled, this indicates if it is running.
true
if the server is runningfalse
, otherwise bool cUPnPServer::restart | ( | void | ) |
Restart the server
When the server is not operating properly it can be restarted. It will stop the server functionalities, clear everything and start it again.
true
, when the server restarted successfullyfalse
, otherwise bool cUPnPServer::setAddress | ( | const char * | Address | ) |
Set the server address
Specifies the servers IP address. The server needs to restart when the IP is changed. However, it's not possible to detect changes through the system.
This method should only be used in cases of fixed IP addresses for example when no DHCP server is available.
Address | The address of the server |
true
, if the new server address is setfalse
, otherwise bool cUPnPServer::setAutoDetection | ( | bool | enable | ) |
Enables oder Disables auto detection mode
If this is set to true, the setup will get it's information via auto detection
enable | true enables and false disables the auto detection |
true
, if the new server address is setfalse
, otherwise bool cUPnPServer::setInterface | ( | const char * | Interface | ) |
The Interface to listen on
Sets the listener interface, for instance 'eth1' or 'wlan0'
Interface | The interface of the server |
true
, if the new server address is setfalse
, otherwise bool cUPnPServer::setServerPort | ( | unsigned short | port | ) |
Set the server port
The port must be in the scope of user definied ports (49152 - 65535). If the port is 0, it is autoassigned. You can retrieve the actual port by calling getServerAddress(), which will give you a structure with the port in it.
The server must be restarted if the IP or port changes.
Returns 1 when the port is valid, 0 otherwise
port | The port of the server |
true
, if the new server port is setfalse
, otherwise bool cUPnPServer::start | ( | void | ) |
Start the UPnP server
This will start the UPnP server activities as a background task.
true
, when the server started successfullyfalse
, otherwise void cUPnPServer::stop | ( | void | ) |
Stop the server
This will stop the server. This means that open connections to any clients and open ports will be closed.