예제 #1
0
void HttpSocket::handleNewConnection()
{
    DBUG;
    while (hasPendingConnections()) {
        QTcpSocket *socket = nextPendingConnection();

        // prevent clients from sending too much data
        socket->setReadBufferSize(constMaxBuffer);

        static const QLatin1String constIpV6Prefix("::ffff:");

        QString peer=socket->peerAddress().toString();
        QString ifaceAddress=serverAddress().toString();
        const bool hostOk=peer==ifaceAddress || peer==mpdAddr || peer==(constIpV6Prefix+mpdAddr) ||
                          peer==QLatin1String("127.0.0.1") || peer==(constIpV6Prefix+QLatin1String("127.0.0.1"));

        DBUG << "peer:" << peer << "mpd:" << mpdAddr << "iface:" << ifaceAddress << "ok:" << hostOk;
        if (!hostOk) {
            sendErrorResponse(socket, 400);
            socket->close();
            DBUG << "Not from valid host";
            return;
        }

        connect(socket, SIGNAL(readyRead()), this, SLOT(readClient()));
        connect(socket, SIGNAL(disconnected()), this, SLOT(discardClient()));
    }
}
예제 #2
0
void HttpSocket::handleNewConnection()
{
    DBUG;
    while (hasPendingConnections()) {
        QTcpSocket *s = nextPendingConnection();
        connect(s, SIGNAL(readyRead()), this, SLOT(readClient()));
        connect(s, SIGNAL(disconnected()), this, SLOT(discardClient()));
    }
}
예제 #3
0
void
LegacyPlayerListener::onNewConnection()
{
    while (hasPendingConnections())
    {
        QTcpSocket* socket = nextPendingConnection();
        connect( socket, SIGNAL(readyRead()), SLOT(onDataReady()) );
    }
}
예제 #4
0
void IdentServer::incomingConnection()
{
    auto server = qobject_cast<QTcpServer*>(sender());
    Q_ASSERT(server);
    while (server->hasPendingConnections()) {
        QTcpSocket* socket = server->nextPendingConnection();
        connect(socket, &QIODevice::readyRead, this, &IdentServer::respond);
        connect(socket, &QAbstractSocket::disconnected, socket, &QObject::deleteLater);
    }
}
예제 #5
0
void
PlayerListener::onNewConnection()
{
    while (hasPendingConnections())
    {
        QObject* o = nextPendingConnection();
        connect( o, SIGNAL(readyRead()), SLOT(onDataReady()) );
        connect( o, SIGNAL(disconnected()), o, SLOT(deleteLater()) );
    }
}
예제 #6
0
void StatusApi::slotNewConnection()
{
    while (hasPendingConnections()) {
        QWebSocket *sock=nextPendingConnection();
        DBUG << (void *)sock;
        connect(sock, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
        clients.append(sock);
        sock->sendTextMessage(statusMessage());
        sock->sendTextMessage(currentSongMessage());
    }
}
void TNotificationServer::handleNewConnection(){
	while(hasPendingConnections()){
		QTcpSocket *tcpCon = nextPendingConnection();
		if(tcpCon!=0){
			TConnection *con = new TConnection;
			con->connection = tcpCon;
			con->lastActive = QDateTime::currentDateTime();
			activeConnections << con;
		}
	}
	waitForNewConnection();
}
예제 #8
0
/*!
 * \reimp
 */
QTcpSocket* QxtSslServer::nextPendingConnection()
{
    if(!hasPendingConnections()) return 0;
    return qxt_d().pendingConnections.dequeue();
}