这篇教程C++ socketError函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中socketError函数的典型用法代码示例。如果您正苦于以下问题:C++ socketError函数的具体用法?C++ socketError怎么用?C++ socketError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了socketError函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: connectHandlerstatic void connectHandler(int fd, void *data, int flags){ privateSocketStruct *pss= (privateSocketStruct *)data; FPRINTF((stderr, "connectHandler(%d, %p, %d)/n", fd, data, flags)); if (flags & AIO_X) /* -- exception */ { /* error during asynchronous connect() */ aioDisable(fd); pss->sockError= socketError(fd); pss->sockState= Unconnected; perror("connectHandler"); } else /* (flags & AIO_W) -- connect completed */ { /* connect() has completed */ int error= socketError(fd); if (error) { FPRINTF((stderr, "connectHandler: error %d (%s)/n", error, strerror(error))); pss->sockError= error; pss->sockState= Unconnected; } else { pss->sockState= Connected; setLinger(pss->s, 1); } } notify(pss, CONN_NOTIFY);}
开发者ID:mohamedfarag,项目名称:RoarVM,代码行数:30,
示例2: htonsbool UdpSocket::listen(uint16_t port){ if (mPriv->listening) return false; sockaddr_in local; local.sin_family = AF_INET; local.sin_addr.s_addr = INADDR_ANY; local.sin_port = htons(port); mPriv->server = socket(AF_INET, SOCK_DGRAM, 0); if (mPriv->server == INVALID_SOCKET) { const int err = socketError(); fprintf(stderr, "socket failed: %d %s/n", err, socketErrorMessage(err).c_str()); return false; } if (bind(mPriv->server, reinterpret_cast<sockaddr*>(&local), sizeof(local))) { const int err = socketError(); fprintf(stderr, "bind on port %d failed: %d %s/n", port, err, socketErrorMessage(err).c_str()); close(mPriv->server); return false; } mPriv->start(); mPriv->listening = true; return true;}
开发者ID:jhanssen,项目名称:missouri,代码行数:27,
示例3: socksswitch_accept/* wrapper for socket accpeting */int socksswitch_accept(const int sock) { SOCKET_ADDR_LEN addrlen = sizeof(struct sockaddr_in); struct sockaddr_in addr; int rc; DEBUG_ENTER; rc = accept(sock, (struct sockaddr *) &addr, &addrlen); /* socket connected */ if (rc > 0) { TRACE_INFO("connect from %s:%i (socket:%i)/n", inet_ntoa(addr.sin_addr), ntohs(addr.sin_port), rc); } /* error */ else { TRACE_WARNING("failure on connecting (socket:%i err:%i): %s/n", sock, SOCKET_ERROR_CODE, socketError()); socketError(); } DEBUG_LEAVE; return rc;}
开发者ID:escoand,项目名称:socksswitch,代码行数:26,
示例4: sendint_t send(int_t s, const void *data, int_t length, int_t flags){ error_t error; size_t written; Socket *socket; //Make sure the socket descriptor is valid if(s < 0 || s >= SOCKET_MAX_COUNT) { socketError(NULL, ERROR_INVALID_SOCKET); return SOCKET_ERROR; } //Point to the socket structure socket = &socketTable[s]; //Send data error = socketSend(socket, data, length, &written, flags << 8); //Any error to report? if(error) { socketError(socket, error); return SOCKET_ERROR; } //Return the number of bytes sent return written;}
开发者ID:hyper123,项目名称:CycloneTCP,代码行数:29,
示例5: QObjectSimondConnector::SimondConnector(QObject *parent) : QObject(parent), state(Unconnected), socket(new QSslSocket(this)), timeoutTimer(new QTimer(this)), response(new QDataStream(socket)), mic(new SoundInput(SOUND_CHANNELS, SOUND_SAMPLERATE, this)), passThroughSound(false){ connect(this, SIGNAL(connectionState(ConnectionState)), this, SLOT(setCurrentState(ConnectionState))); connect(socket, SIGNAL(readyRead()), this, SLOT(messageReceived())); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError())); connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(socketError())); connect(socket, SIGNAL(connected()), this, SLOT(connectionEstablished())); connect(socket, SIGNAL(encrypted()), this, SLOT(connectionEstablished())); connect(socket, SIGNAL(disconnected()), this, SLOT(connectionLost())); connect(mic, SIGNAL(error(QString)), this, SIGNAL(error(QString))); connect(mic, SIGNAL(microphoneLevel(int,int,int)), this, SIGNAL(microphoneLevel(int,int,int))); connect(mic, SIGNAL(listening()), this, SLOT(startRecording())); connect(mic, SIGNAL(complete()), this, SLOT(commitRecording())); connect(mic, SIGNAL(readyRead()), this, SLOT(soundDataAvailable())); connect(timeoutTimer, SIGNAL(timeout()), this, SLOT(timeoutReached())); timeoutTimer->setSingleShot(true); timeoutTimer->setInterval(SOCKET_TIMEOUT);}
开发者ID:KDE,项目名称:simon-tools,代码行数:26,
示例6: recvint_t recv(int_t s, void *data, int_t size, int_t flags){ error_t error; size_t received; Socket *socket; //Make sure the socket descriptor is valid if(s < 0 || s >= SOCKET_MAX_COUNT) { socketError(NULL, ERROR_INVALID_SOCKET); return SOCKET_ERROR; } //Point to the socket structure socket = &socketTable[s]; //Receive data error = socketReceive(socket, data, size, &received, flags << 8); //Any error to report? if(error) { socketError(socket, error); return SOCKET_ERROR; } //Return the number of bytes received return received;}
开发者ID:hyper123,项目名称:CycloneTCP,代码行数:29,
示例7: shutdownint_t shutdown(int_t s, int_t how){ error_t error; Socket *socket; //Make sure the socket descriptor is valid if(s < 0 || s >= SOCKET_MAX_COUNT) { socketError(NULL, ERROR_INVALID_SOCKET); return SOCKET_ERROR; } //Point to the socket structure socket = &socketTable[s]; //Shutdown socket error = socketShutdown(socket, how); //Any error to report? if(error) { socketError(socket, error); return SOCKET_ERROR; } //Successful processing return SOCKET_SUCCESS;}
开发者ID:hyper123,项目名称:CycloneTCP,代码行数:28,
示例8: applicationNamevoid ClientApplication::start() { if (!parseCommandLine()) { QMessageBox::critical(NULL, applicationName(), trUtf8("Error in the command line arguments. Arguments:/n--host <h>/tConnect to the server on host <h>./n--local/tRun client locally./n--port <p>/tUse port <p> to connect to the server.")); quit(); return; } if (mode == mUnspecified) { ConnectDialog connectDialog; int code = connectDialog.exec(); if (code == QDialog::Rejected) { quit(); return; } if (connectDialog.local()) { mode = mLocal; } else { mode = mRemote; host = connectDialog.host(); port = connectDialog.port(); } } if (mode == mLocal) { theTrainer.reset(new Trainer()); showMainWindow(); } else { ProxyTrainer *trainer = new ProxyTrainer(); theTrainer.reset(trainer); connect(trainer, SIGNAL(socketConnected()), SLOT(showMainWindow())); connect(trainer, SIGNAL(socketDisconnected()), SLOT(socketDisconnected())); connect(trainer, SIGNAL(socketError(QString)), SLOT(socketError(QString))); trainer->socketConnectToHost(host, port); }}
开发者ID:odelande,项目名称:QGameTrainer,代码行数:35,
示例9: listenint_t listen(int_t s, int_t backlog){ error_t error; Socket *socket; //Make sure the socket descriptor is valid if(s < 0 || s >= SOCKET_MAX_COUNT) { socketError(NULL, ERROR_INVALID_SOCKET); return SOCKET_ERROR; } //Point to the socket structure socket = &socketTable[s]; //Place the socket in the listening state error = socketListen(socket); //Any error to report? if(error) { socketError(socket, error); return SOCKET_ERROR; } //Successful processing return SOCKET_SUCCESS;}
开发者ID:hyper123,项目名称:CycloneTCP,代码行数:28,
示例10: masterSocket/* create and bind master socket */int masterSocket(const int port) { int rc; struct sockaddr_in addr; DEBUG_ENTER; /* create master socket */ rc = socket(AF_INET, SOCK_STREAM, 0); if (rc == SOCKET_ERROR) { TRACE_ERROR("master socket create (err:%i): %s/n", SOCKET_ERROR_CODE, socketError()); DEBUG_LEAVE; return 0; } TRACE_VERBOSE("master socket created: %i/n", rc); DEBUG; /* set socket non blocking */#ifdef WIN32 unsigned long nValue = 1; ioctlsocket(rc, FIONBIO, &nValue);#endif DEBUG; /* bind master socket */ addr.sin_family = AF_INET; addr.sin_addr.s_addr = INADDR_ANY; addr.sin_port = htons(port); if (bind (rc, (struct sockaddr *) &addr, sizeof(struct sockaddr_in)) == SOCKET_ERROR) { TRACE_ERROR("failure on binding socket (err:%i): %s/n", SOCKET_ERROR_CODE, socketError()); DEBUG_LEAVE; exit(1); } TRACE_VERBOSE("master socket bound: %i/n", rc); DEBUG; /* listen master socket */ if (listen(rc, 128) == SOCKET_ERROR) { TRACE_ERROR("failure on listening (err:%i): %s/n", SOCKET_ERROR_CODE, socketError()); DEBUG_LEAVE; exit(1); } TRACE_INFO("listening on *:%d (socket:%i)/n", port, rc); DEBUG_LEAVE; return rc;}
开发者ID:escoand,项目名称:socksswitch,代码行数:56,
示例11: FD_ZEROvoid UdpSocketPrivate::run(){ sockaddr_in from; socklen_t fromlen; int ret; timeval tv; fd_set fds; char buf[4096]; for (;;) { tv.tv_sec = 5; tv.tv_usec = 0; FD_ZERO(&fds); FD_SET(server, &fds); ret = select(server + 1, &fds, 0, 0, &tv); if (ret == SOCKET_ERROR) { const int err = socketError(); fprintf(stderr, "socket failed: %d %s/n", err, UdpSocket::socketErrorMessage(err).c_str()); return; } else if (ret > 0) { assert(FD_ISSET(server, &fds)); bool done; do { done = true; fromlen = sizeof(from); ret = recvfrom(server, buf, sizeof(buf), 0, reinterpret_cast<sockaddr*>(&from), &fromlen); if (ret == SOCKET_ERROR) { const int err = socketError(); if (err == EINTR) done = false; else { fprintf(stderr, "socket recvfrom failed: %d %s/n", err, UdpSocket::socketErrorMessage(err).c_str()); return; } } //printf("got socket data %d/n", ret); if (callback && !callback(buf, ret, userData)) { return; } } while (!done); } //printf("server wakeup/n"); MutexLocker locker(&mutex); if (stopped) return; }}
开发者ID:jhanssen,项目名称:missouri,代码行数:50,
示例12: trvoid MainWindow::startServer(){ if(!db || !db->isOpen()) { QMessageBox::information(this, tr("No database"), tr("you need to configure database for server at first...")); return; } if(server) { server->close(); delete server; } server = new FSEServer(this); server->setDatabase(db); connect(server, SIGNAL(acceptError(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); connect(server, SIGNAL(errorString(QString)), this, SLOT(logCollect(QString))); connect(server, SIGNAL(debugString(QString)), this, SLOT(logCollect(QString))); if(server->listen(QHostAddress(IPv4), serverPort)) { logCollect(tr("start to listen ") + IPv4 + ":" +QString::number(serverPort)); stateChange(ServerWorking); } else { qDebug() << "start failed" << server->serverError(); stopServer(); }}
开发者ID:ChepenSmilelife,项目名称:fse-server,代码行数:31,
示例13: path/*! Constructs an assistant client with the given /a parent. The /a path specifies the path to the Qt Assistant executable. If /a path is an empty string the system path (/c{%PATH%} or /c $PATH) is used.*/QAssistantClient::QAssistantClient( const QString &path, QObject *parent ) : QObject( parent ), host ( QLatin1String("localhost") ){ if ( path.isEmpty() ) assistantCommand = QLatin1String("assistant"); else { QFileInfo fi( path ); if ( fi.isDir() ) assistantCommand = path + QLatin1String("/assistant"); else assistantCommand = path; }#if defined(Q_OS_MAC) assistantCommand += QLatin1String(".app/Contents/MacOS/assistant");#endif socket = new QTcpSocket( this ); connect( socket, SIGNAL(connected()), SLOT(socketConnected()) ); connect( socket, SIGNAL(disconnected()), SLOT(socketConnectionClosed()) ); connect( socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError()) ); opened = false; proc = new QProcess( this ); port = 0; pageBuffer = QLatin1String(""); connect( proc, SIGNAL(readyReadStandardError()), this, SLOT(readStdError()) ); connect( proc, SIGNAL(error(QProcess::ProcessError)), this, SLOT(procError(QProcess::ProcessError)) );}
开发者ID:CreativeLabs0X3CF,项目名称:deveditor,代码行数:39,
示例14: mPortIndiClient::IndiClient(const int &attempts) : mPort(indi::PORT), mAttempts(attempts), mAttempt(1){ connect(&mQTcpSocket, SIGNAL(connected()), SLOT(socketConnected())); connect(&mQTcpSocket, SIGNAL(disconnected()), SLOT(socketDisconnected())); connect(&mQTcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError))); connect(&mQTcpSocket, SIGNAL(readyRead()), SLOT(socketReadyRead()));}
开发者ID:aaronevers,项目名称:indi-fcgi,代码行数:7,
示例15: qDebug//! [clientConnected]void TennisServer::clientConnected(){ qDebug() << Q_FUNC_INFO << "connect"; QBluetoothSocket *socket = l2capServer->nextPendingConnection(); if (!socket) return; if(clientSocket){ qDebug() << Q_FUNC_INFO << "Closing socket!"; delete socket; return; } connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket())); connect(socket, SIGNAL(disconnected()), this, SLOT(clientDisconnected())); connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(socketError(QBluetoothSocket::SocketError))); stream = new QDataStream(socket); clientSocket = socket; qDebug() << Q_FUNC_INFO << "started"; emit clientConnected(clientSocket->peerName()); lagTimer.start();}
开发者ID:KDE,项目名称:android-qt-mobility,代码行数:28,
示例16: QObjectFilezillaAdminConnection::FilezillaAdminConnection(QObject *parent) : QObject(parent){ mSocket = new QTcpSocket(); connect(mSocket, SIGNAL(readyRead()), this, SLOT(bytesToRead())); connect(mSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError)));}
开发者ID:Shakti213,项目名称:FilezillaUserAdmin,代码行数:7,
示例17: QObjectTSock::TSock(QTcpSocket *sock, QObject *parent) : QObject(parent), listenPort(0){ if (sock == NULL) socket = new QTcpSocket; else socket = sock; connect(socket, SIGNAL(connected()), this, SLOT(socketConnected())); connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); connect(socket, SIGNAL(readyRead()), this, SLOT(socketDataReady())); connect(&server, SIGNAL(newConnection()), this, SLOT(serverConnection()));}
开发者ID:Tomatix,项目名称:IdealIRC,代码行数:26,
示例18: ifvoid MessageQueue::writeData() { if(_sendbuflen==0) { // If send buffer is empty, serialize the next message in the queue. // The snapshot upload queue has lower priority than the normal queue. if(!_sendqueue.isEmpty()) { // There are messages in the higher priority queue, send one _sendbuflen = _sendqueue.dequeue()->serialize(_sendbuffer); } else if(!_snapshot_send.isEmpty()) { // If there is nothing in the normal send queue, check if // there is something in the lower priority snapshot queue SnapshotMode mode(SnapshotMode::SNAPSHOT); _sendbuflen = mode.serialize(_sendbuffer); _sendbuflen += _snapshot_send.takeFirst()->serialize(_sendbuffer + _sendbuflen); } } if(_sentcount < _sendbuflen) { int sent = _socket->write(_sendbuffer+_sentcount, _sendbuflen-_sentcount); if(sent<0) { // Error emit socketError(_socket->errorString()); return; } _sentcount += sent; if(_sentcount == _sendbuflen) { _sendbuflen=0; _sentcount=0; if(_closeWhenReady) close(); else writeData(); } }}
开发者ID:Acru,项目名称:Drawpile,代码行数:34,
示例19: nameSmtpClient::SmtpClient(const QString & host, int port, ConnectionType ct) : name("localhost"), authMethod(AuthPlain), connectionTimeout(5000), responseTimeout(5000){ if (ct == TcpConnection) this->useSsl = false; else if (ct == SslConnection) this->useSsl = true; if (useSsl == false) socket = new QTcpSocket(this); else socket = new QSslSocket(this); this->host = host; this->port = port; connect(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState))); connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); connect(socket, SIGNAL(readyRead()), this, SLOT(socketReadyRead()));}
开发者ID:MatiasNAmendola,项目名称:PythonIde,代码行数:26,
示例20: socksswitch_close/* wrapper for socket closing */int socksswitch_close(const int sock) { char addrstr[256]; DEBUG_ENTER; if (sock <= 0) { DEBUG_LEAVE; return 0; } strcpy(addrstr, socksswitch_addr(sock)); /* disconnect */ if (shutdown(sock, SD_BOTH) == 0 && SOCKET_CLOSE(sock) == 0) TRACE_INFO("disconnected from %s (socket:%i)/n", addrstr, sock); /* error */ else { TRACE_WARNING ("failure on closing from %s (socket:%i err:%i): %s/n", addrstr, sock, SOCKET_ERROR_CODE, socketError()); DEBUG_LEAVE; return SOCKET_ERROR; } DEBUG_LEAVE; return 1;}
开发者ID:escoand,项目名称:socksswitch,代码行数:29,
示例21: startingConnect/*! Connect to the configured port and host for the device and setting up the socket.*/void DeviceConnector::connect(){ if ( mSocket ) // already connected return; emit startingConnect(); loginDone = false; mSocket = new QTcpSocket(); QObject::connect( mSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError()) ); mSocket->connectToHost( QHostAddress( "10.10.10.20" ), 4245 ); if ( !mSocket->waitForConnected() ) { emit deviceConnMessage( tr( "Error connecting to device:" ) + mSocket->errorString() ); delete mSocket; mSocket = 0; return; } QObject::connect( mSocket, SIGNAL(readyRead()), this, SLOT(socketReadyRead()) ); QObject::connect( mSocket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()) ); emit deviceConnMessage( tr( "Device connected" ) ); emit finishedConnect();}
开发者ID:Camelek,项目名称:qtmoko,代码行数:29,
示例22: QMutexvoid SslClient::establish(const QString& host, quint16 port){ threadLock_ = new QMutex(); threadEvent_ = new QWaitCondition(); QMutexLocker blocked(threadLock_); host_ = host; port_ = port; start(); threadEvent_->wait(threadLock_); if(ssl_.isNull() || running_ == false) Q_ASSERT_X(ssl_.isNull() || running_ == false, "SslClient::establish", "Cannot start SslClient's thread"); connect(ssl_.data(), SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(socketStateChanged(QAbstractSocket::SocketState)), Qt::DirectConnection); connect(ssl_.data(), SIGNAL(encrypted()), this, SLOT(socketEncrypted()), Qt::DirectConnection); connect(ssl_.data(), SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError)), Qt::DirectConnection); connect(ssl_.data(), SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(sslErrors(QList<QSslError>)), Qt::DirectConnection); connect(ssl_.data(), SIGNAL(readyRead()), this, SLOT(socketReadyRead()), Qt::DirectConnection); ConfigureForLMAX();}
开发者ID:agandzyuk,项目名称:huobi_grider,代码行数:28,
示例23: QTcpSocketvoid Connection::connect(QString h,int p) { host=h; port=p; // cleanup previous object, if any if (tcpSocket) { delete tcpSocket; } tcpSocket=new QTcpSocket(this); QObject::connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(socketError(QAbstractSocket::SocketError))); QObject::connect(tcpSocket, SIGNAL(connected()), this, SLOT(connected())); QObject::connect(tcpSocket, SIGNAL(disconnected()), this, SLOT(disconnected())); QObject::connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(socketData())); // set the initial state state=READ_HEADER_TYPE; // cleanup dirty value eventually left from previous usage bytes=0; qDebug() << "Connection::connect: connectToHost: " << host << ":" << port; tcpSocket->connectToHost(host,port);}
开发者ID:Excalibur201010,项目名称:ghpsdr3-alex,代码行数:31,
示例24: QTcpSocketbool MjpegClient::connectTo(const QString& host, int port, QString url, const QString& user, const QString& pass){ if(url.isEmpty()) url = "/"; m_host = host; m_port = port > 0 ? port : 80; m_url = url; m_user = user; m_pass = pass; if(m_socket) { m_socket->abort(); delete m_socket; m_socket = 0; } m_socket = new QTcpSocket(this); connect(m_socket, SIGNAL(readyRead()), this, SLOT(dataReady())); connect(m_socket, SIGNAL(disconnected()), this, SLOT(lostConnection())); connect(m_socket, SIGNAL(disconnected()), this, SIGNAL(socketDisconnected())); connect(m_socket, SIGNAL(connected()), this, SIGNAL(socketConnected())); connect(m_socket, SIGNAL(connected()), this, SLOT(connectionReady())); connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(socketError(QAbstractSocket::SocketError))); connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(lostConnection(QAbstractSocket::SocketError))); m_socket->connectToHost(host,port); m_socket->setReadBufferSize(1024 * 1024); return true;}
开发者ID:dtbinh,项目名称:dviz,代码行数:32,
示例25: GameStatevoid MainWindow::on_connectButton_clicked(){ if(m_connectionState == ConnectionState::Disconnected) { QString host = ui->hostLineEdit->text(); quint16 port = ui->portSpinBox->value(); QString name = ui->nameLineEdit->text(); m_tcpClient.reset(new nc::TcpClient); m_gameState.reset(new GameState(host, port, name, *m_tcpClient.get())); connect(m_tcpClient.get(), SIGNAL(messageRead(QByteArray)), m_gameState.get(), SLOT(onInboundMessage(QByteArray))); connect(m_gameState.get(), SIGNAL(outboundMessage(QByteArray)), m_tcpClient.get(), SLOT(writeMessage(QByteArray))); connect(m_gameState.get(), SIGNAL(chatMessageReceived(QString)), this, SLOT(onChatMessageReceived(QString))); connect(m_gameState.get(), SIGNAL(disconnectedFromServer(QString)), this, SLOT(onDisconnected(QString))); connect(this, SIGNAL(chatMessageSent(QString)), m_gameState.get(), SLOT(onChatMessageSent(QString))); connect(m_tcpClient.get(), SIGNAL(connected()), this, SLOT(onConnected())); connect(m_tcpClient.get(), SIGNAL(disconnected()), this, SLOT(onDisconnected())); connect(m_tcpClient.get(), SIGNAL(socketError(QAbstractSocket::SocketError)), this, SLOT(onSocketError(QAbstractSocket::SocketError))); m_tcpClient->connectToHost(host, port); changeConnectionState(ConnectionState::Connecting); qDebug() << "Connecting."; appendHtml(QString("<b>Connecting to %1:%2.</b><br>").arg(host).arg(port)); } else { m_tcpClient->disconnectFromHost(); }}
开发者ID:tehme,项目名称:Outlaw,代码行数:31,
示例26: initvoid SocketImpl::connect(const SocketAddress& address, const Poco::Timespan& timeout){ if (_sockfd == POCO_INVALID_SOCKET) { init(address.af()); } setBlocking(false); try {#if defined(POCO_VXWORKS) int rc = ::connect(_sockfd, (sockaddr*) address.addr(), address.length());#else int rc = ::connect(_sockfd, address.addr(), address.length());#endif if (rc != 0) { int err = lastError(); if (err != POCO_EINPROGRESS && err != POCO_EWOULDBLOCK) error(err, address.toString()); if (!poll(timeout, SELECT_READ | SELECT_WRITE | SELECT_ERROR)) throw Poco::TimeoutException("connect timed out", address.toString()); err = socketError(); if (err != 0) error(err); } } catch (Poco::Exception&) { setBlocking(true); throw; } setBlocking(true);}
开发者ID:12307,项目名称:poco,代码行数:32,
示例27: setMessagevoid PingPong::clientConnected(){ //! [Initiating server socket] if (!m_serverInfo->hasPendingConnections()) { setMessage("FAIL: expected pending server connection"); return; } socket = m_serverInfo->nextPendingConnection(); if (!socket) return; socket->setParent(this); connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket())); connect(socket, SIGNAL(disconnected()), this, SLOT(clientDisconnected())); connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(socketError(QBluetoothSocket::SocketError))); //! [Initiating server socket] setMessage(QStringLiteral("Client connected.")); QByteArray size; size.setNum(m_boardWidth); size.append(' '); QByteArray size1; size1.setNum(m_boardHeight); size.append(size1); size.append(" /n"); socket->write(size.constData());}
开发者ID:lollinus,项目名称:qt-5.3-examples,代码行数:28,
示例28: QObjectBtLocalDevice::BtLocalDevice(QObject *parent) : QObject(parent), securityFlags(QBluetooth::NoSecurity){ localDevice = new QBluetoothLocalDevice(this); connect(localDevice, SIGNAL(error(QBluetoothLocalDevice::Error)), this, SIGNAL(error(QBluetoothLocalDevice::Error))); connect(localDevice, SIGNAL(hostModeStateChanged(QBluetoothLocalDevice::HostMode)), this, SIGNAL(hostModeStateChanged())); connect(localDevice, SIGNAL(pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing)), this, SLOT(pairingFinished(QBluetoothAddress,QBluetoothLocalDevice::Pairing))); connect(localDevice, SIGNAL(deviceConnected(QBluetoothAddress)), this, SLOT(connected(QBluetoothAddress))); connect(localDevice, SIGNAL(deviceDisconnected(QBluetoothAddress)), this, SLOT(disconnected(QBluetoothAddress))); connect(localDevice, SIGNAL(pairingDisplayConfirmation(QBluetoothAddress,QString)), this, SLOT(pairingDisplayConfirmation(QBluetoothAddress,QString))); if (localDevice->isValid()) { deviceAgent = new QBluetoothDeviceDiscoveryAgent(this); connect(deviceAgent, SIGNAL(deviceDiscovered(QBluetoothDeviceInfo)), this, SLOT(deviceDiscovered(QBluetoothDeviceInfo))); connect(deviceAgent, SIGNAL(finished()), this, SLOT(discoveryFinished())); connect(deviceAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)), this, SLOT(discoveryError(QBluetoothDeviceDiscoveryAgent::Error))); connect(deviceAgent, SIGNAL(canceled()), this, SLOT(discoveryCanceled())); serviceAgent = new QBluetoothServiceDiscoveryAgent(this); connect(serviceAgent, SIGNAL(serviceDiscovered(QBluetoothServiceInfo)), this, SLOT(serviceDiscovered(QBluetoothServiceInfo))); connect(serviceAgent, SIGNAL(finished()), this, SLOT(serviceDiscoveryFinished())); connect(serviceAgent, SIGNAL(canceled()), this, SLOT(serviceDiscoveryCanceled())); connect(serviceAgent, SIGNAL(error(QBluetoothServiceDiscoveryAgent::Error)), this, SLOT(serviceDiscoveryError(QBluetoothServiceDiscoveryAgent::Error))); socket = new QBluetoothSocket(SOCKET_PROTOCOL, this); connect(socket, SIGNAL(stateChanged(QBluetoothSocket::SocketState)), this, SLOT(socketStateChanged(QBluetoothSocket::SocketState))); connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(socketError(QBluetoothSocket::SocketError))); connect(socket, SIGNAL(connected()), this, SLOT(socketConnected())); connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected())); connect(socket, SIGNAL(readyRead()), this, SLOT(readData())); setSecFlags(socket->preferredSecurityFlags()); server = new QBluetoothServer(SOCKET_PROTOCOL, this); connect(server, SIGNAL(newConnection()), this, SLOT(serverNewConnection())); connect(server, SIGNAL(error(QBluetoothServer::Error)), this, SLOT(serverError(QBluetoothServer::Error))); } else { deviceAgent = 0; serviceAgent = 0; socket = 0; server = 0; }}
开发者ID:OniLink,项目名称:Qt5-Rehost,代码行数:59,
注:本文中的socketError函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ socketPtr函数代码示例 C++ socketClose函数代码示例 |