本文整理汇总了C++中readSocket函数的典型用法代码示例。如果您正苦于以下问题:C++ readSocket函数的具体用法?C++ readSocket怎么用?C++ readSocket使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了readSocket函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
开发者ID:KDE,项目名称:android-qt-mobility,代码行数:28,代码来源:tennisserver.cpp
示例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()));
}
开发者ID:diepdtnse03145,项目名称:Qt-IPC-Server-Client,代码行数:7,代码来源:qserver.cpp
示例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);
}
开发者ID:NanoSim,项目名称:Porto,代码行数:7,代码来源:httpserver.cpp
示例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());
}
开发者ID:lollinus,项目名称:qt-5.3-examples,代码行数:28,代码来源:pingpong.cpp
示例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();
}
开发者ID:kmkaplan,项目名称:QtBitcoinTrader,代码行数:26,代码来源:socketthread.cpp
示例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__ << "<<";
}
开发者ID:lainwir3d,项目名称:qtconnectivity,代码行数:27,代码来源:rfcommclient.cpp
示例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()));
}
开发者ID:KarstenSN,项目名称:E4PRJ4,代码行数:31,代码来源:mainwindow.cpp
示例8: while
void LocalSocketConnection::start()
{
if (m_socket) {
m_holdRequests = false;
while (m_socket->bytesAvailable() != 0)
readSocket();
}
}
开发者ID:OpenChemistry,项目名称:molequeue,代码行数:8,代码来源:localsocketconnection.cpp
示例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);
}
开发者ID:WecodezFox,项目名称:FoxFramework,代码行数:9,代码来源:connection.cpp
示例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());
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:12,代码来源:chatserver.cpp
示例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;
}
}
}
开发者ID:BenJneB,项目名称:LINGI1341,代码行数:53,代码来源:receiver.c
示例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();
}
开发者ID:stunami,项目名称:mythtv,代码行数:13,代码来源:lcdserver.cpp
示例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()));
}
开发者ID:Summeli,项目名称:iCP4Qt,代码行数:14,代码来源:icontrolpadclient.cpp
示例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()));
}
开发者ID:kaltsi,项目名称:qt-mobility,代码行数:16,代码来源:chatclient.cpp
示例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";
}
开发者ID:Kuihku,项目名称:QMLMultiComputer,代码行数:16,代码来源:runnerview.cpp
示例16: QTcpSocket
void ServerThread::run()
{
_tcpSocket = new QTcpSocket();
//qDebug () << "Setting socket descriptor " << _socketDescriptor;
if (!_tcpSocket->setSocketDescriptor(_socketDescriptor))
{
qDebug() << "Cant set socket descriptor " << _socketDescriptor << " " << _tcpSocket->errorString();
return;
}
connect(_tcpSocket, SIGNAL(readyRead()), this, SLOT(readSocket()), Qt::DirectConnection);
connect(_tcpSocket, SIGNAL(disconnected()), this, SLOT(handleSocketDisconnect()), Qt::DirectConnection);
exec();
}
开发者ID:roFilip,项目名称:COMP8005_A2,代码行数:17,代码来源:serverthread.cpp
示例17: readSocket
void *testReaderUnix(void *)
{
UDDSocket readSocket("testDestination");
readSocket.nonblocking();
int rc = 0;
while (rc<gNumToSend) {
char buf[MAX_UDP_LENGTH];
int count = readSocket.read(buf);
if (count>0) {
COUT("read: " << buf);
rc++;
} else {
sleep(2);
}
}
return NULL;
}
开发者ID:57-Wolve,项目名称:OpenBTS-UMTS,代码行数:17,代码来源:SocketsTest.cpp
示例18: listen
int ServerSocket::listenOnSocket()
{
int listenErr = listen(this->sockfd, BACKLOG);
if (listenErr != 0) {
printf("\nSocket Listen FAILED! %d\n", errno);
return cleanup();
}
printf("\nListening on %d...", PORT);
acceptConnection();
printf("\nConnection Accepted!");
char *buf = new char[128];
char *start = buf;
int len = readSocket(buf);
printf("\nReceived %d bytes", len);
printf("\nReceived %s", start);
writeToSocket("RESPONSE");
return 0;
}
开发者ID:majorsaber,项目名称:sockets,代码行数:18,代码来源:ServerSocket.cpp
示例19: disconnect
void LocalSocketConnection::setSocket(QLocalSocket *socket)
{
if (m_socket != NULL) {
m_socket->abort();
m_socket->disconnect(this);
disconnect(m_socket);
m_socket->deleteLater();
}
if (socket != NULL) {
connect(socket, SIGNAL(readyRead()),
this, SLOT(readSocket()));
connect(socket, SIGNAL(disconnected()),
this, SIGNAL(disconnected()));
connect(socket, SIGNAL(destroyed()),
this, SLOT(socketDestroyed()));
}
m_dataStream->setDevice(socket);
m_dataStream->setVersion(QDataStream::Qt_4_8);
m_socket = socket;
}
开发者ID:OpenChemistry,项目名称:molequeue,代码行数:20,代码来源:localsocketconnection.cpp
示例20: error
void QxThread::doProcess(QTcpSocket & socket)
{
if (! socket.setSocketDescriptor(m_iSocketDescriptor))
{
Q_EMIT error("[QxOrm] invalid socket descriptor : cannot start transaction", QxTransaction_ptr());
return;
}
qx_bool bReadOk = readSocket(socket);
if (! bReadOk) {
Q_EMIT error(QString("[QxOrm] unable to read request from socket : '") + bReadOk.getDesc() + QString("'"), QxTransaction_ptr());
return;
}
if (! m_bIsRunning) {
return;
}
Q_EMIT transactionStarted(m_pTransaction);
try {
m_pTransaction->executeServer();
}
catch (const qx::exception & x) {
qx_bool xb = x.toQxBool();
m_pTransaction->setMessageReturn(xb);
}
catch (const std::exception & e) {
m_pTransaction->setMessageReturn(qx_bool(QX_ERROR_UNKNOWN, e.what()));
}
catch (...) {
m_pTransaction->setMessageReturn(qx_bool(QX_ERROR_UNKNOWN, "unknown error"));
}
if (! m_bIsRunning) {
return;
}
qx_bool bWriteOk = writeSocket(socket);
if (! bWriteOk) {
Q_EMIT error(QString("[QxOrm] unable to write reply to socket : '") + bWriteOk.getDesc() + QString("'"), m_pTransaction);
}
Q_EMIT transactionFinished(m_pTransaction);
}
开发者ID:jgh0721,项目名称:iMonPlatform,代码行数:41,代码来源:QxThread.cpp
注:本文中的readSocket函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论