-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver1.cpp
More file actions
33 lines (29 loc) · 807 Bytes
/
server1.cpp
File metadata and controls
33 lines (29 loc) · 807 Bytes
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
#include "server1.h"
Server1::Server1(QObject *parent)
: QTcpServer{parent}
{
dial.show();
if(this->listen(QHostAddress::Any,12))
qDebug() << "Listening port is " << this->serverPort();
}
void Server1::incomingConnection(qintptr socketDescriptor)
{
socket = new QTcpSocket;
socket->setSocketDescriptor(socketDescriptor);
connect(socket,SIGNAL(readyRead()),SLOT(slotReadyRead()));
connect(socket,SIGNAL(disconnected()),SLOT(deleteLater()));
}
void Server1::slotReadyRead()
{
socket = (QTcpSocket*)sender();
bool flag;
QImage img;
QDataStream in(socket);
if(in.status() == QDataStream::Ok)
{
in.setVersion(QDataStream::Qt_6_0);
in >> img >> flag;
qDebug() << "flag is " << flag;
dial.takeImage(img,flag);
}
}