本文整理汇总了C++中readSocket函数的典型用法代码示例。如果您正苦于以下问题:C++ readSocket函数的具体用法?C++ readSocket怎么用?C++ readSocket使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readSocket函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: connect
void QServer::addToList(QLocalSocket* socket)
{
//Store sockets & connect them for read & discard them on disconnect
connection_list.push_back(socket);
connect(socket, SIGNAL(readyRead()), this , SLOT(readSocket()));
connect(socket, SIGNAL(disconnected()), this , SLOT(discardSocket()));
}
示例3: incomingConnection
void HttpServer :: incomingConnection(qintptr socketDescriptor)
{
auto socket = new QTcpSocket (this);
connect (socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
connect (socket, SIGNAL(disconnected()), this, SLOT(disconnectSocket()));
socket->setSocketDescriptor(socketDescriptor);
}
示例4: setMessage
void 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());
}
示例5: connect
void SocketThread::run()
{
{
queryTime.restart();
if(isLogEnabled)logThread->writeLog("SocketThread Started");
sslSocket=new QSslSocket;
connect(this,SIGNAL(sendToApiSignal(QByteArray, QByteArray)),this,SLOT(sendToApiSlot(QByteArray, QByteArray)));
connect(this,SIGNAL(reconnectApiSignal()),this,SLOT(reconnectApiSlot()));
connect(sslSocket,SIGNAL(readyRead()),SLOT(readSocket()));
secondTimer=new QTimer;
connect(secondTimer,SIGNAL(timeout()),this,SLOT(secondSlot()));
if(useSSL)sslSocket->connectToHostEncrypted(hostName, 443);
else sslSocket->connectToHost(hostName, 80);
sslSocket->waitForConnected();
if(isLogEnabled)
{
logThread->writeLog("SSL Socket state:"+sslSocket->errorString().toAscii()+". Supported: "+QByteArray::number(sslSocket->supportsSsl()));
}
secondTimer->start(100);
sendPendingData();
}
exec();
}
示例6: qDebug
//! [startClient]
void RfCommClient::startClient(const QBluetoothServiceInfo &remoteService)
{
qDebug() << __PRETTY_FUNCTION__ << ">>";
serviceInfo = remoteService;
// make sure preconditions are met
if (!powerOn() || socket) {
qDebug() << __PRETTY_FUNCTION__ << "<< power not on or socket already exists!";
return;
}
// Connect to service
if (state == listening)
state = pendingConnections;
socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket);
qDebug() << "Create socket";
socket->connectToService(remoteService);
qDebug() << "ConnecttoService done";
connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
connect(socket, SIGNAL(connected()), this, SLOT(connected()));
connect(socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
connect(socket, SIGNAL(error(QBluetoothSocket::SocketError)), this, SLOT(error(QBluetoothSocket::SocketError)));
qDebug() << __PRETTY_FUNCTION__ << "<<";
}
示例7: QMainWindow
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent), ui(new Ui::MainWindow),media(0)
{
isConnected=false;
controllerConnected=false;
ui->setupUi(this);
this->setWindowTitle("Au2");
instance = new VlcInstance(VlcCommon::args(), this);
player = new VlcMediaPlayer(instance);
player->setVideoWidget(ui->video);
readDataFromFile();
data[1] = 0;//hastighed
data[2] = 0;//afstand
data[3] = 0;//acceleration
data[4] = 1;//AKS = on
ui->AKS->setText("AKS-On");
updateData();
connect(ui->OpretForbindelse, SIGNAL(clicked()), this, SLOT(Au2connect()));
connect(ui->KonfigurerIP, SIGNAL(clicked()), this, SLOT(konfigurerIP()));
connect(ui->AKS, SIGNAL(clicked()), this, SLOT(AKSstatus()));
connect(ui->IndstilMaksHastighed, SIGNAL(clicked()), this, SLOT(maksHastighed()));
connect(ui->KalibrerStyretoj, SIGNAL(clicked()), this, SLOT(kalibrerStyretoj()));
connect(ui->LukNed, SIGNAL(clicked()), this, SLOT(shutDown()));
connect(this, SIGNAL(sig_getData()), this, SLOT(readSocket()));
}
示例8: while
void LocalSocketConnection::start()
{
if (m_socket) {
m_holdRequests = false;
while (m_socket->bytesAvailable() != 0)
readSocket();
}
}
示例9: QObject
Connection::Connection(QObject *parent) :
QObject(parent)
{
conection = new QLocalSocket(this);
connect(conection,SIGNAL(readyRead()),this,SLOT(readSocket()));
connect(conection,SIGNAL(disconnected()),this,SLOT(discardSocket()));
conection->connectToServer(Packets::server_name_tag);
}
示例10: connect
//! [clientConnected]
void ChatServer::clientConnected()
{
QBluetoothSocket *socket = rfcommServer->nextPendingConnection();
if (!socket)
return;
connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
connect(socket, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
clientSockets.append(socket);
emit clientConnected(socket->peerName());
}
示例11: receiver
void receiver(int socket, char *filename)
{
fd_set read, write;
char readed[520];
int f;
if(filename==NULL)
f=STDOUT_FILENO;
else
f=open(filename,O_WRONLY|O_CREAT|O_TRUNC);
while(1){
FD_ZERO(&read);
FD_ZERO(&write);
FD_SET(socket,&write);
FD_SET(socket,&read);
FD_SET(f,&write);
if(select(socket+1,&read,&write, NULL,NULL)==-1)
{
fprintf(stderr,"Error selectreceiver\n");
return;
}
if(FD_ISSET(socket,&write) && FD_ISSET(socket,&read))
{
printf("receiver readwritesocket\n");
int rd=readSocket(socket,readed,520);
if(rd>=0)
{
pkt_t *pkt=pkt_new();
pkt_status_code errdec=pkt_decode((const char *)readed,(size_t)rd,pkt);
printf("lu : %s\n",pkt_get_payload(pkt));
if(errdec==PKT_OK)
{
if(pkt_get_type(pkt)==PTYPE_DATA)
{
printf("On doit créer ACK/NACK\n");
}
}
else
{
fprintf(stderr,"Error receiver decode\n");
return;
}
pkt_del(pkt);
printf("after del\n");
}
}
else if(FD_ISSET(f,&write))
{
printf("Write file\n");
break;
}
}
}
示例12: connect
void LCDServer::newConnection(QTcpSocket *socket)
{
connect(socket, SIGNAL(readyRead()),
this, SLOT( readSocket()));
connect(socket, SIGNAL(disconnected()),
this, SLOT( endConnection()));
if (debug_level > 0)
LOG(VB_NETWORK, LOG_INFO, "LCDServer: new connection");
if (m_lcd)
m_lcd->switchToTime();
}
示例13: QBluetoothSocket
void iControlPadClient::connectToService(const QBluetoothServiceInfo &remoteService)
{
if (m_socket)
return;
// Connect to service
m_socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket);
qDebug() << "Create socket";
m_socket->connectToService(remoteService);
qDebug() << "Connecte Service done";
connect(m_socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
connect(m_socket, SIGNAL(connected()), this, SLOT(connected()));
connect(m_socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
}
示例14: QBluetoothSocket
//! [startClient]
void ChatClient::startClient(const QBluetoothServiceInfo &remoteService)
{
if (socket)
return;
// Connect to service
socket = new QBluetoothSocket(QBluetoothSocket::RfcommSocket);
qDebug() << "Create socket";
socket->connectToService(remoteService);
qDebug() << "ConnecttoService done";
connect(socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
connect(socket, SIGNAL(connected()), this, SLOT(connected()));
connect(socket, SIGNAL(disconnected()), this, SIGNAL(disconnected()));
}
示例15: QQuickWidget
RunnerView::RunnerView(QString appUid, QString server, QWidget* parent) :
QQuickWidget(parent),
m_appUid(appUid),
m_socket(new QLocalSocket(this)),
m_shared(new QSharedMemory(appUid, this))
{
qDebug() << "RunnerView::RunnerView";
connect(engine(), SIGNAL(quit()), this, SLOT(quitApplication()));
connect(m_socket, SIGNAL(connected()), this, SLOT(socketConnected()));
connect(m_socket, SIGNAL(disconnected()), this, SLOT(socketDisconnected()));
connect(m_socket, SIGNAL(error(QLocalSocket::LocalSocketError)), this, SLOT(socketError(QLocalSocket::LocalSocketError)));
connect(m_socket, SIGNAL(bytesWritten(qint64)), this, SLOT(socketBytesWritten(qint64)));
connect(m_socket, SIGNAL(readyRead()), this, SLOT(readSocket()));
m_socket->connectToServer(server);
qDebug() << "RunnerView::RunnerView - END";
}