diff --git a/src/Server.cpp b/src/Server.cpp index c9b5d17..82a1bc6 100644 --- a/src/Server.cpp +++ b/src/Server.cpp @@ -11,11 +11,14 @@ Server::Server(QObject *parent) : QObject(parent) { bool Server::start() { connect(m_tcp_server, SIGNAL(newConnection()), this, SLOT(handleConnection())); - return m_tcp_server->listen(QHostAddress::Any, 9200); + return m_tcp_server->listen(QHostAddress::Any, 0); +} + +quint16 Server::server_port() const { + return m_tcp_server->serverPort(); } void Server::handleConnection() { QTcpSocket *socket = m_tcp_server->nextPendingConnection(); new Connection(socket, m_page, this); } - diff --git a/src/Server.h b/src/Server.h index fadccee..69f881b 100644 --- a/src/Server.h +++ b/src/Server.h @@ -9,6 +9,7 @@ class Server : public QObject { public: Server(QObject *parent = 0); bool start(); + quint16 server_port() const; public slots: void handleConnection(); diff --git a/src/main.cpp b/src/main.cpp index b1f4557..f931373 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,9 +11,10 @@ int main(int argc, char **argv) { Server server; if (server.start()) { + std::cerr << "Capybara-webkit server started, listening on port: " << server.server_port() << std::endl; return app.exec(); } else { - std::cerr << "Couldn't start server" << std::endl; + std::cerr << "Couldn't start capybara-webkit server" << std::endl; return 1; } }