-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpeer.cc
More file actions
38 lines (33 loc) · 884 Bytes
/
peer.cc
File metadata and controls
38 lines (33 loc) · 884 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
34
35
36
37
38
#include "peer.hh"
Peer::Peer(QHostAddress address, quint16 port) {
this->address = address;
this->port = port;
}
//
//Peer::Peer(QString input) {
// QStringList list = input.split(':');
// if (list.length() == 2) {
// QHostInfo::lookupHost(list[0], this, SLOT(process(QHostInfo)));
// port = static_cast<quint16>(list[1].toUInt());
// }
//
//}
void Peer::process(QHostInfo q) {
if (q.error() != QHostInfo::NoError) {
qDebug() << "Lookup failed:" << q.errorString();
} else {
this->host = q.hostName();
this->address = q.addresses().first();
qDebug() << q.hostName();
qDebug() << q.addresses().first().toString();
}
}
const QString &Peer::getHost() const {
return host;
}
const QHostAddress &Peer::getAddress() const {
return address;
}
quint16 Peer::getPort() const {
return port;
}