#include "ratecontroller.h"
#include "peerwireclient.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
{
Q_OBJECT
public slots:
void showData()
{
PeerWireClient *socket = (RcTcpSocket *)sender();
//QTcpSocket *socket = (QTcpSocket *)sender();
while (socket->canReadLine())
qDebug() << socket->readLine();
}
void onExit()
{
PeerWireClient *socket = (PeerWireClient *)sender();
qDebug() << "bytesAvailable: " << socket->bytesAvailable();
qDebug() << "socketBytesAvailable: " << socket->socketBytesAvailable();
qDebug() << "canReadLine: " << socket->canReadLine();
qDebug() << "socketCanReadLine: " << socket->QTcpSocket::canReadLine();
}
};
int main(int argc, char **argv)
{
RateController controller;
controller.setUploadLimit(100);
controller.setDownloadLimit(100);
PeerWireClient socket;
controller.addSocket(&PeerWireClient);
socket.connectToHost("qt.nokia.com", 80);
Foo foo;
QObject::connect(&socket,
SIGNAL(readyRead
()),
&foo,
SLOT(showData
()));
QObject::connect(&socket,
SIGNAL(readChannelFinished
()),
&foo,
SLOT(onExit
()));
//QObject::connect(&socket, SIGNAL(readChannelFinished()), &app, SLOT(exit()));
socket.write("GET / HTTP/1.0\r\n\r\n");
return app.exec();
}
#include "main.moc"
#include "ratecontroller.h"
#include "peerwireclient.h"
#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
class Foo : public QObject
{
Q_OBJECT
public slots:
void showData()
{
PeerWireClient *socket = (RcTcpSocket *)sender();
//QTcpSocket *socket = (QTcpSocket *)sender();
while (socket->canReadLine())
qDebug() << socket->readLine();
}
void onExit()
{
PeerWireClient *socket = (PeerWireClient *)sender();
qDebug() << "bytesAvailable: " << socket->bytesAvailable();
qDebug() << "socketBytesAvailable: " << socket->socketBytesAvailable();
qDebug() << "canReadLine: " << socket->canReadLine();
qDebug() << "socketCanReadLine: " << socket->QTcpSocket::canReadLine();
}
};
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
RateController controller;
controller.setUploadLimit(100);
controller.setDownloadLimit(100);
PeerWireClient socket;
controller.addSocket(&PeerWireClient);
socket.connectToHost("qt.nokia.com", 80);
Foo foo;
QObject::connect(&socket, SIGNAL(readyRead()), &foo, SLOT(showData()));
QObject::connect(&socket, SIGNAL(readChannelFinished()), &foo, SLOT(onExit()));
//QObject::connect(&socket, SIGNAL(readChannelFinished()), &app, SLOT(exit()));
socket.write("GET / HTTP/1.0\r\n\r\n");
return app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
Bookmarks