| 134 | } |
| 135 | |
| 136 | bool LocalPeer::isClient() |
| 137 | { |
| 138 | if (lockFile->isLocked()) |
| 139 | return false; |
| 140 | |
| 141 | if (!lockFile->lock(LockedFile::WriteLock, false)) |
| 142 | return true; |
| 143 | |
| 144 | bool res = server->listen(socketName); |
| 145 | #if defined(Q_OS_UNIX) |
| 146 | // ### Workaround |
| 147 | if (!res && server->serverError() == QAbstractSocket::AddressInUseError) { |
| 148 | QFile::remove(QDir::cleanPath(QDir::tempPath())+QLatin1Char('/')+socketName); |
| 149 | res = server->listen(socketName); |
| 150 | } |
| 151 | #endif |
| 152 | if (!res) |
| 153 | qWarning("QtSingleCoreApplication: listen on local socket failed, %s", qPrintable(server->errorString())); |
| 154 | QObject::connect(server.get(), SIGNAL(newConnection()), SLOT(receiveConnection())); |
| 155 | return false; |
| 156 | } |
| 157 | |
| 158 | |
| 159 | bool LocalPeer::sendMessage(const QByteArray &message, int timeout) |
no test coverage detected