summaryrefslogtreecommitdiff
path: root/libs/networking/src
diff options
context:
space:
mode:
authorgeronimo <geronimo013@gmx.de>2012-07-13 04:17:43 (GMT)
committergeronimo <geronimo013@gmx.de>2012-07-13 04:17:43 (GMT)
commit8d311771df7448ada1410bfce0993fdaa3698106 (patch)
tree90d37c7238ac2b46ec05a2ba1acbd8cec6af6dea /libs/networking/src
parente9237d65ac03840de56e50cacf95001273bcff59 (diff)
downloadcmp-8d311771df7448ada1410bfce0993fdaa3698106.tar.gz
cmp-8d311771df7448ada1410bfce0993fdaa3698106.tar.bz2
added basic commandline support for cmps
Diffstat (limited to 'libs/networking/src')
-rw-r--r--libs/networking/src/HTTPServer.cc14
-rw-r--r--libs/networking/src/ServerConfig.cc17
-rw-r--r--libs/networking/src/ServerSocket.cc35
3 files changed, 46 insertions, 20 deletions
diff --git a/libs/networking/src/HTTPServer.cc b/libs/networking/src/HTTPServer.cc
index f435e2f..3b9757b 100644
--- a/libs/networking/src/HTTPServer.cc
+++ b/libs/networking/src/HTTPServer.cc
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: HTTPServer.cc
* Created: 4. Juli 2012, 12:16
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: libnetworking: classes for tcp/ip sockets and http-protocol handling
- *
+ *
* CMP - compound media player
- *
+ *
* is a client/server mediaplayer intended to play any media from any workstation
* without the need to export or mount shares. cmps is an easy to use backend
* with a (ready to use) HTML-interface. Additionally the backend supports
* authentication via HTTP-digest authorization.
* cmpc is a client with vdr-like osd-menues.
- *
+ *
* Copyright (c) 2012 Reinhard Mantey, some rights reserved!
* published under Creative Commons by-sa
* For details see http://creativecommons.org/licenses/by-sa/3.0/
- *
+ *
* The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
- *
+ *
* --------------------------------------------------------------
*/
#include <HTTPServer.h>
@@ -66,6 +66,8 @@ void cHTTPServer::Action()
}
#endif
fprintf(stderr, "startup server now\n");
+
+ ServerSocket().Open();
while (Running()) {
cConnectionPoint *cp = ServerSocket().Accept();
diff --git a/libs/networking/src/ServerConfig.cc b/libs/networking/src/ServerConfig.cc
index e6ad4b8..d749264 100644
--- a/libs/networking/src/ServerConfig.cc
+++ b/libs/networking/src/ServerConfig.cc
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: ServerConfig.cc
* Created: 8. Juli 2012, 06:12
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: libnetworking: classes for tcp/ip sockets and http-protocol handling
- *
+ *
* CMP - compound media player
- *
+ *
* is a client/server mediaplayer intended to play any media from any workstation
* without the need to export or mount shares. cmps is an easy to use backend
* with a (ready to use) HTML-interface. Additionally the backend supports
* authentication via HTTP-digest authorization.
* cmpc is a client with vdr-like osd-menues.
- *
+ *
* Copyright (c) 2012 Reinhard Mantey, some rights reserved!
* published under Creative Commons by-sa
* For details see http://creativecommons.org/licenses/by-sa/3.0/
- *
+ *
* The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
- *
+ *
* --------------------------------------------------------------
*/
#include <ServerConfig.h>
@@ -57,4 +57,9 @@ void cServerConfig::SetDocumentRoot(const char* DocumentRoot)
{
free(documentRoot);
documentRoot = DocumentRoot ? strdup(DocumentRoot) : NULL;
+}
+
+void cServerConfig::SetPort(int port)
+{
+ server.SetPort(port);
} \ No newline at end of file
diff --git a/libs/networking/src/ServerSocket.cc b/libs/networking/src/ServerSocket.cc
index 2ff92fb..ae51a18 100644
--- a/libs/networking/src/ServerSocket.cc
+++ b/libs/networking/src/ServerSocket.cc
@@ -1,25 +1,25 @@
/**
* ======================== legal notice ======================
- *
+ *
* File: ServerSocket.cc
* Created: 4. Juli 2012, 07:28
* Author: <a href="mailto:geronimo013@gmx.de">Geronimo</a>
* Project: libnetworking: classes for tcp/ip sockets and http-protocol handling
- *
+ *
* CMP - compound media player
- *
+ *
* is a client/server mediaplayer intended to play any media from any workstation
* without the need to export or mount shares. cmps is an easy to use backend
* with a (ready to use) HTML-interface. Additionally the backend supports
* authentication via HTTP-digest authorization.
* cmpc is a client with vdr-like osd-menues.
- *
+ *
* Copyright (c) 2012 Reinhard Mantey, some rights reserved!
* published under Creative Commons by-sa
* For details see http://creativecommons.org/licenses/by-sa/3.0/
- *
+ *
* The cmp project's homepage is at http://projects.vdr-developer.org/projects/cmp
- *
+ *
* --------------------------------------------------------------
*/
#include <ServerSocket.h>
@@ -29,7 +29,7 @@
cServerSocket::cServerSocket(int Port, int Queue)
: cAbstractSocket(Port, Queue)
, port(Port)
- , active(true)
+ , active(false)
{
}
@@ -39,7 +39,17 @@ cServerSocket::~cServerSocket()
bool cServerSocket::Open(void)
{
- return cAbstractSocket::Open(port);
+ bool rv = cAbstractSocket::Open(port);
+
+ if (rv) active = true;
+
+ return rv;
+}
+
+void cServerSocket::Close(void)
+{
+ active = false;
+ cAbstractSocket::Close();
}
cConnectionPoint *cServerSocket::Accept(void)
@@ -82,3 +92,12 @@ bool cServerSocket::ForceBlockingIO() const
{
return cAbstractSocket::ForceBlockingIO();
}
+
+void cServerSocket::SetPort(int Port)
+{
+ if (active) {
+ esyslog("ERROR: server socket is already active! Can't change port settings!");
+ return;
+ }
+ port = Port;
+} \ No newline at end of file