aboutsummaryrefslogtreecommitdiff
path: root/client/mytcpsocket.cpp
blob: 92dd67a95091585340008fd81992143ea17643ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <mytcpsocket.h>

MyTcpSocket::MyTcpSocket(QObject *parent) :
    QObject(parent)
{
}

void MyTcpSocket::doConnect()
{
    socket = new QTcpSocket(this);

    connect(socket, SIGNAL(connected()),this, SLOT(connected()));
    connect(socket, SIGNAL(disconnected()),this, SLOT(disconnected()));
   // connect(socket, SIGNAL(bytesWritten(qint64)),this, SLOT(bytesWritten(qint64)));
    connect(socket, SIGNAL(readyRead()),this, SLOT(readyRead()));
    qDebug() << "connectig...";

    socket->connectToHost("192.168.137.141",80);

    if(!socket->waitForConnected(5000)){
        qDebug()<<"Error: "<< socket->errorString();
    }
}

void MyTcpSocket::connected(){
    qDebug() << "connected...";

    socket->write("Weerdata: Temp:?\r\n\r\n\r\n\r\n");

}
void MyTcpSocket::disconnected(){
    qDebug() << "disconnected...";

}

void MyTcpSocket::bytesWritten(qint64 bytes){
    qDebug() << bytes << "bytes written...";

}
void MyTcpSocket::readyRead(){
    qDebug() << "reading...";

    qDebug() << socket->readAll();
}