bool WebSocketsClient::reconnect() { Synchronized<FastLockR> _(lock); if (listener == null && url.empty()) return false; connectInternal(); return true; }
bool QHttpSocketEngine::connectToHostByName(const QString &hostname, quint16 port) { Q_D(QHttpSocketEngine); setPeerAddress(QHostAddress()); setPeerPort(port); d->peerName = hostname; return connectInternal(); }
bool QHttpSocketEngine::connectToHost(const QHostAddress &address, quint16 port) { Q_D(QHttpSocketEngine); setPeerAddress(address); setPeerPort(port); d->peerName.clear(); return connectInternal(); }
void WebSocketsClient::connect(ConstStrA url, PNetworkEventListener listener) { Synchronized<FastLockR> _(lock); if (this->listener != null) { disconnect(); } this->url = url; this->listener = listener.getMT(); connectInternal(); }
bool SocketClient::connectTcp(const String& host, uint16_t port, int maxTime) { sockaddr_in addr; if (!lookupHost(host, port, addr)) return false; mMode = Tcp; bool ok = false; if (connectInternal(mFd, AF_INET, reinterpret_cast<sockaddr*>(&addr), sizeof(sockaddr_in), maxTime)) { ok = true; unsigned int fdflags = EventLoop::Read; if (!mBuffers.empty()) fdflags |= EventLoop::Write; EventLoop::instance()->addFileDescriptor(mFd, fdflags, dataCallback, this); mConnected(this); } return ok; }
bool SocketClient::connectUnix(const Path& path, int maxTime) { sockaddr_un unAddress; memset(&unAddress, 0, sizeof(sockaddr_un)); unAddress.sun_family = AF_UNIX; const int sz = std::min<int>(sizeof(unAddress.sun_path) - 1, path.size()); memcpy(unAddress.sun_path, path.constData(), sz); unAddress.sun_path[sz] = '\0'; mMode = Unix; if (connectInternal(mFd, PF_UNIX, reinterpret_cast<sockaddr*>(&unAddress), sizeof(sockaddr_un), maxTime)) { unsigned int fdflags = EventLoop::Read; if (!mBuffers.empty()) fdflags |= EventLoop::Write; EventLoop::instance()->addFileDescriptor(mFd, fdflags, dataCallback, this); mConnected(this); return true; } return false; }