48 #ifndef QT_NO_LOCALSERVER 50 #include <sys/socket.h> 58 # include <selectLib.h> 97 if (-1 == listenSocket) {
104 struct ::sockaddr_un addr;
105 addr.sun_family = PF_UNIX;
123 int flags =
fcntl(listenSocket, F_GETFL, 0);
125 || -1 == (
fcntl(listenSocket, F_SETFL, flags | O_NONBLOCK))) {
133 if(-1 == QT_SOCKET_BIND(listenSocket, (sockaddr *)&addr,
sizeof(sockaddr_un))) {
136 if(
errno == EADDRINUSE)
157 q->connect(socketNotifier,
SIGNAL(activated(
int)),
170 if (socketNotifier) {
171 socketNotifier->setEnabled(
false);
172 socketNotifier->deleteLater();
176 if (-1 != listenSocket)
196 if (-1 == listenSocket)
201 int connectedSocket =
qt_safe_accept(listenSocket, (sockaddr *)&addr, &length);
202 if(-1 == connectedSocket) {
208 q->incomingConnection(connectedSocket);
216 FD_SET(listenSocket, &readfds);
219 timeout.tv_sec = msec / 1000;
220 timeout.tv_usec = (msec % 1000) * 1000;
223 result =
qt_safe_select(listenSocket + 1, &readfds, 0, 0, (msec == -1) ? 0 : &timeout);
231 *timedOut = (result == 0);
261 #if defined QLOCALSERVER_DEBUG 269 #endif // QT_NO_LOCALSERVER
int maxPendingConnections
bool listen(const QString &name)
void waitForNewConnection(int msec, bool *timedOut)
#define QT_END_NAMESPACE
This macro expands to.
char * data()
Returns a pointer to the data stored in the byte array.
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
The QSocketNotifier class provides support for monitoring activity on a file descriptor.
bool exists() const
Returns true if the file specified by fileName() exists; otherwise returns false. ...
void _q_onNewConnection()
We have received a notification that we can read on the listen socket.
#define QT_BEGIN_NAMESPACE
This macro expands to.
QQueue< QLocalSocket * > pendingConnections
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Q_CORE_EXPORT void qWarning(const char *,...)
The QLocalServer class provides a local socket based server.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
static QString cleanPath(const QString &path)
Removes all multiple directory separators "/" and resolves any "."s or ".."s found in the path...
void setError(const QString &function)
static QString tempPath()
Returns the absolute path of the system's temporary directory.
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept, const struct timeval *orig_timeout)
static int qt_safe_socket(int domain, int type, int protocol, int flags=0)
static int qt_safe_accept(int s, struct sockaddr *addr, QT_SOCKLEN_T *addrlen, int flags=0)
int size() const
Returns the number of items in the list.
QAbstractSocket::SocketError error
int size() const
Returns the number of bytes in this byte array.
static int qt_safe_listen(int s, int backlog)
bool remove()
Removes the file specified by fileName().
static QString fileName(const QString &fileUrl)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
static bool removeServer(const QString &name)