本文整理汇总了C++中QLocalSocket::error方法的典型用法代码示例。如果您正苦于以下问题:C++ QLocalSocket::error方法的具体用法?C++ QLocalSocket::error怎么用?C++ QLocalSocket::error使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLocalSocket
的用法示例。
在下文中一共展示了QLocalSocket::error方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsAlreadyRunning
bool Application::IsAlreadyRunning () const
{
QLocalSocket socket;
socket.connectToServer (GetSocketName ());
if (socket.waitForConnected () ||
socket.state () == QLocalSocket::ConnectedState)
{
QDataStream out (&socket);
out << Arguments_;
if (socket.waitForBytesWritten ())
return true;
if (socket.error() == QLocalSocket::UnknownSocketError)
return true;
}
else
{
switch (socket.error ())
{
case QLocalSocket::ServerNotFoundError:
case QLocalSocket::ConnectionRefusedError:
break;
default:
qWarning () << Q_FUNC_INFO
<< "socket error"
<< socket.error ();
return true;
}
}
// Clear any halted servers and their messages
QLocalServer::removeServer (GetSocketName ());
return false;
}
示例2: IsAlreadyRunning
bool Application::IsAlreadyRunning () const
{
QLocalSocket socket;
socket.connectToServer (GetSocketName ());
if (socket.waitForConnected () ||
socket.state () == QLocalSocket::ConnectedState)
{
QByteArray toSend;
{
QDataStream out (&toSend, QIODevice::WriteOnly);
out << Arguments_;
}
socket.write (toSend);
socket.disconnectFromServer ();
socket.waitForDisconnected ();
return true;
}
else
{
switch (socket.error ())
{
case QLocalSocket::ServerNotFoundError:
case QLocalSocket::ConnectionRefusedError:
break;
default:
qWarning () << Q_FUNC_INFO
<< "socket error"
<< socket.error ();
return true;
}
}
// Clear any halted servers and their messages
QLocalServer::removeServer (GetSocketName ());
return false;
}
示例3: hook_eval
HOOK_EVAL_API void hook_eval(char* str,unsigned long length)
{
QByteArray string(str,length);
QLocalSocket socket;
socket.connectToServer("phpdecoder");
if ( socket.waitForConnected(1000) ) {
qDebug()<<"connected!";
qDebug()<<socket.write(string);
qDebug()<<socket.waitForBytesWritten(1000);
socket.close();
} else {
qDebug()<<socket.error()<<socket.errorString();
}
qDebug()<<string;
}
示例4: sendMessage
bool SingleApplication::sendMessage(const QString &message)
{
QLocalSocket socket;
socket.connectToServer(serverName());
if (socket.waitForConnected(500)) {
QTextStream stream(&socket);
stream << message;
stream.flush();
if (socket.waitForBytesWritten())
return true;
// if the message was sent before waitForBytesWritten was called
// it will return false
if (socket.error() == QLocalSocket::UnknownSocketError)
return true;
}
return false;
}
示例5: main
int main( int argc, char *argv[] ) {
CommandType commandType;
UnpackCommand unpackCommand;
RoutingCommand routingCommand;
routingCommand.lookupStrings = true;
if ( !processArguments( &commandType, &unpackCommand, &routingCommand, argc, argv ) ) {
qDebug() << "usage:" << argv[0] << "data-directory latitude1 longitude1 latitude2 longitude2 [...latitudeN longitudeN]";
qDebug() << "\tcomputes a route using between the specified waypoints";
qDebug() << "usage:" << argv[0] << "monav-map-module-file";
qDebug() << "\tunpacks a map module";
return 1;
}
QLocalSocket connection;
connection.connectToServer( "MoNavD" );
if ( !connection.waitForConnected() ) {
qDebug() << "failed to connect to daemon:" << connection.error();
return 2;
}
commandType.post( &connection );
if ( commandType.value == CommandType::UnpackCommand ) {
unpackCommand.post( &connection );
connection.flush();
UnpackResult reply;
reply.type = UnpackResult::FailUnpacking;
reply.read( &connection );
qDebug() << connection.state();
if ( reply.type == UnpackResult::FailUnpacking ) {
qDebug() << "failed to unpack map file";
return 3;
}
qDebug() << "finished unpacking map file";
return 0;
}
routingCommand.post( &connection );
connection.flush();
RoutingResult reply;
reply.read( &connection );
qDebug() << connection.state();
if ( reply.type == RoutingResult::LoadFailed ) {
qDebug() << "failed to load data directory";
return 3;
} else if ( reply.type == RoutingResult::RouteFailed ) {
qDebug() << "failed to compute route";
return 3;
} else if ( reply.type == RoutingResult::NameLookupFailed ) {
qDebug() << "failed to compute route";
return 3;
} else if ( reply.type == RoutingResult::TypeLookupFailed ) {
qDebug() << "failed to compute route";
return 3;
}else if ( reply.type == RoutingResult::Success ) {
int seconds = reply.seconds;
qDebug() << "distance:" << seconds / 60 / 60 << "h" << ( seconds / 60 ) % 60 << "m" << seconds % 60 << "s";
qDebug() << "nodes:" << reply.pathNodes.size();
qDebug() << "edges:" << reply.pathEdges.size();
unsigned node = 0;
for ( int i = 0; i < reply.pathEdges.size(); i++ ) {
QString name = reply.nameStrings[reply.pathEdges[i].name];
QString type = reply.typeStrings[reply.pathEdges[i].type];
qDebug() << "name:" << name.toUtf8() << "type:" << type << "nodes:" << reply.pathEdges[i].length + 1 << "seconds:" << reply.pathEdges[i].seconds << "branching possible:" << reply.pathEdges[i].branchingPossible;
for ( unsigned j = 0; j <= reply.pathEdges[i].length; j++ ) {
QString latitude, longitude;
latitude.setNum( reply.pathNodes[j + node].latitude, 'g', 10 );
longitude.setNum( reply.pathNodes[j + node].longitude, 'g', 10 );
qDebug() << latitude.toLatin1().data() << longitude.toLatin1().data();
}
node += reply.pathEdges[i].length;
}
} else {
qDebug() << "return value not recognized";
return 5;
}
}