IpcServer Class

The IpcServer listens on a port and creates an IpcConnection for an incoming connection. More...

Header: #include <IpcServer>

Public Functions

IpcServer(QObject *parent = 0)
void listen(int port)
void setMaxConnections(int num)

Signals

void clientConnected(const QHostAddress &address)
void clientConnected(QTcpSocket *socket)
void clientDisconnected(QTcpSocket *socket)
void clientDisconnected(const QHostAddress &address)
void received(const QString &method, const QByteArray &content)

Detailed Description

The IpcServer listens on a port and creates an IpcConnection for an incoming connection.

The IPC server receives a method call from the client an notifies the user through the IpcServer::received signal.

{.cpp}
   m_server = new IpcServer(this);
   connect(m_server, &IpcServer::received, this, &MyHandler::handleCall);
   m_server->listen(10234);

   ...

   MyHandler::handleCall(const QString& method, const QByteArray& contnt) {
     if (method == "echo(QString)") {
       QString text;
       QDataStream in(content);
       in >> text;
       qDebug() << "call received: " << method << ": " << text;
     }
   }

Member Function Documentation

IpcServer::IpcServer(QObject *parent = 0)

Standard constructor using parent as parent object

[signal] void IpcServer::clientConnected(const QHostAddress &address)

Called when a new client connection is established, providing the address

Note: Signal clientConnected is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:

connect(ipcServer, static_cast<void(IpcServer::*)(const QHostAddress &)>(&IpcServer::clientConnected),
    [=](const QHostAddress &address){ /* ... */ });

[signal] void IpcServer::clientConnected(QTcpSocket *socket)

* Called when a new client connection is established, providing the socket

Note: Signal clientConnected is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:

connect(ipcServer, static_cast<void(IpcServer::*)(QTcpSocket *)>(&IpcServer::clientConnected),
    [=](QTcpSocket *socket){ /* ... */ });

[signal] void IpcServer::clientDisconnected(QTcpSocket *socket)

* Called when an existing client connection is dropped, providing the socket

Note: Signal clientDisconnected is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:

connect(ipcServer, static_cast<void(IpcServer::*)(QTcpSocket *)>(&IpcServer::clientDisconnected),
    [=](QTcpSocket *socket){ /* ... */ });

[signal] void IpcServer::clientDisconnected(const QHostAddress &address)

Called when an existing client connection is dropped, providing the address

Note: Signal clientDisconnected is overloaded in this class. To connect to this one using the function pointer syntax, you must specify the signal type in a static cast, as shown in this example:

connect(ipcServer, static_cast<void(IpcServer::*)(const QHostAddress &)>(&IpcServer::clientDisconnected),
    [=](const QHostAddress &address){ /* ... */ });

void IpcServer::listen(int port)

listens to incomong connections on port

[signal] void IpcServer::received(const QString &method, const QByteArray &content)

signals a IPC call has arrived

A IPC call requesting method and using content a the parameters for the method

void IpcServer::setMaxConnections(int num)

Sets the maximal nuber of pending connections to num

© 2016 Pelagicore AG. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.