From 980947122307797e1d8da03f768d8f14a360d20b Mon Sep 17 00:00:00 2001 From: Andrew Stanley-Jones Date: Thu, 9 Feb 2012 15:51:22 +0100 Subject: Allow the QLocalServer to listen to a native descriptor QLocalServer could only listen to sockets it created. Thi is not always possible as sockets may be passed by socketpair() or have to be created locally by other means. This adds a similar feature to QLocalSocket where a native descriptor maybe used. Change-Id: I43b0af179b3b868dd164d4e1fd312ff4546cf9ff Reviewed-by: Michalina Ziemba Reviewed-by: Tapani Mikola Reviewed-by: Harald Fernengel --- src/network/socket/qlocalserver.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'src/network/socket/qlocalserver.cpp') diff --git a/src/network/socket/qlocalserver.cpp b/src/network/socket/qlocalserver.cpp index 97f5920171..05f26883d3 100644 --- a/src/network/socket/qlocalserver.cpp +++ b/src/network/socket/qlocalserver.cpp @@ -298,6 +298,40 @@ bool QLocalServer::listen(const QString &name) return true; } +/*! + \since 5.0 + + Instructs the server to listen for incoming connections on + \a socketDescriptor. The property returns \c false if the server is + currently listening. It returns \c true on success; otherwise, + it returns \c false. The socket must be ready to accept + new connections with no extra platform-specific functions + called. The socket is set into non-blocking mode. + + serverName(), fullServerName() may return a string with + a name if this option is supported by the platform; + otherwise, they return an empty QString. + + \sa isListening(), close() + */ +bool QLocalServer::listen(qintptr socketDescriptor) +{ + Q_D(QLocalServer); + if (isListening()) { + qWarning("QLocalServer::listen() called when already listening"); + return false; + } + + d->serverName.clear(); + d->fullServerName.clear(); + + if (!d->listen(socketDescriptor)) { + return false; + } + + return true; +} + /*! Returns the maximum number of pending accepted connections. The default is 30. -- cgit v1.2.3