本文整理汇总了C++中QAbstractSocket::peerAddress方法的典型用法代码示例。如果您正苦于以下问题:C++ QAbstractSocket::peerAddress方法的具体用法?C++ QAbstractSocket::peerAddress怎么用?C++ QAbstractSocket::peerAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAbstractSocket
的用法示例。
在下文中一共展示了QAbstractSocket::peerAddress方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QString
QString SignalProxy::IODevicePeer::address() const {
QAbstractSocket *socket = qobject_cast<QAbstractSocket *>(_device);
if(socket)
return socket->peerAddress().toString();
else
return QString();
}
示例2: authenticate
/**
* @see http://tools.ietf.org/html/rfc1929
*
* Once the SOCKS V5 server has started, and the client has selected the
* Username/Password Authentication protocol, the Username/Password
* subnegotiation begins. This begins with the client producing a
* Username/Password request:
*
* +----+------+----------+------+----------+
* |VER | ULEN | UNAME | PLEN | PASSWD |
* +----+------+----------+------+----------+
* | 1 | 1 | 1 to 255 | 1 | 1 to 255 |
* +----+------+----------+------+----------+
*
* The VER field contains the current version of the subnegotiation,
* which is X'01'. The ULEN field contains the length of the UNAME field
* that follows. The UNAME field contains the username as known to the
* source operating system. The PLEN field contains the length of the
* PASSWD field that follows. The PASSWD field contains the password
* association with the given UNAME.
*/
void Worker::authenticate(void)
{
int size = this->m_buf.size();
if (-1 == this->m_expected_length) {
if (size > 1) {
quint8 ver = static_cast<quint8>(this->m_buf.at(0));
int ulen = static_cast<quint8>(this->m_buf.at(1));
if (size > 2 + ulen) {
int plen = static_cast<quint8>(this->m_buf.at(ulen + 2));
this->m_expected_length = ulen + plen + 3;
}
if (ver != 1) {
this->m_state = Worker::FatalErrorState;
Q_EMIT this->error(Worker::ProtocolVersionMismatch);
return;
}
}
}
if (this->m_expected_length != -1 && size > this->m_expected_length) {
this->m_state = Worker::FatalErrorState;
Q_EMIT this->error(Worker::TooMuchData);
return;
}
if (size == this->m_expected_length) {
int ulen = static_cast<quint8>(this->m_buf.at(1));
int plen = static_cast<quint8>(this->m_buf.at(ulen + 2));
QByteArray username = ulen ? QByteArray(this->m_buf.constData() + 2, ulen) : QByteArray();
QByteArray password = plen ? QByteArray(this->m_buf.constData() + 2 + ulen + 1, plen) : QByteArray();
QByteArray hostname;
this->m_expected_length = -1;
this->m_buf.clear();
QAbstractSocket* sock = qobject_cast<QAbstractSocket*>(this->m_peer);
if (sock) {
hostname = sock->peerAddress().toString().toLocal8Bit();
}
if (this->m_noauth_allowed && username.isEmpty() && password.isEmpty()) {
this->acceptAuthentication();
}
else {
Q_EMIT this->authenticateRequest(username, password, hostname);
}
}
}
示例3: newConection
void Controler::newConection(){
QAbstractSocket * socket = tcpServer->nextPendingConnection();
qDebug()<<trUtf8("Получено соединение: %1:%2").arg(socket->peerAddress().toString()).arg(socket->peerPort());
}