42 #include "qplatformdefs.h" 45 #ifndef QT_NO_QWS_MULTIPROCESS 60 # define SOCK_STREAM 2 64 #if defined(Q_OS_SOLARIS) || defined (QT_LINUXBASE) 68 # define SUN_LEN(su) \ 69 sizeof(*(su)) - sizeof((su)->sun_path) + strlen((su)->sun_path) 74 # define AF_LOCAL AF_UNIX 77 # define PF_LOCAL PF_UNIX 79 #endif // Q_OS_SOLARIS || QT_LINUXBASE 108 case NonexistentPath:
124 case UnconnectedState:
142 perror(
"QWSSocketAuth::connectToLocalFile could not connect:" );
149 int s = ::socket(PF_LOCAL, SOCK_STREAM, 0);
152 struct sockaddr_un a;
153 memset(&a, 0,
sizeof(a));
154 a.sun_family = PF_LOCAL;
156 int r = ::connect(s, (
struct sockaddr*)&a, SUN_LEN(&a));
158 setSocketDescriptor(s);
160 perror(
"QWSSocket::connectToLocalFile could not connect:");
211 int s = ::socket(PF_LOCAL, SOCK_STREAM, 0);
213 perror(
"QWSServerSocket::init");
214 qWarning(
"QWSServerSocket: unable to create socket.");
222 struct sockaddr_un a;
223 memset(&a, 0,
sizeof(a));
224 a.sun_family = PF_LOCAL;
225 strncpy(a.sun_path, fn.
constData(),
sizeof(a.sun_path) - 1);
226 int r = ::bind(s, (
struct sockaddr*)&a, SUN_LEN(&a));
228 perror(
"QWSServerSocket::init");
235 perror(
"QWSServerSocket::init");
242 if (::listen(s, backlog) == 0) {
243 if (!setSocketDescriptor(s))
244 qWarning(
"QWSServerSocket could not set descriptor %d : %s", s,
errorString().toLatin1().constData());
246 perror(
"QWSServerSocket::init");
261 inboundConnections.append( socketDescriptor );
262 emit newConnection();
269 if ( inboundConnections.count() == 0 )
272 s->setSocketDescriptor( inboundConnections.takeFirst() );
280 #endif //QT_NO_QWS_MULTIPROCESS void forwardStateChange(SocketState)
#define QT_END_NAMESPACE
This macro expands to.
The QByteArray class provides an array of bytes.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
SocketState
The SocketState enumeration represents the connection state of a QUnixSocket instance.
bool listen(const QByteArray &path)
Tells the server to listen for incoming connections on path.
The QString class provides a Unicode character string.
The QObject class is the base class of all Qt objects.
QWSSocket(QObject *parent=0)
#define QT_BEGIN_NAMESPACE
This macro expands to.
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
void error(QAbstractSocket::SocketError)
SocketError
This enum describes the socket errors that can occur.
Q_CORE_EXPORT void qWarning(const char *,...)
bool connectToLocalFile(const QString &file)
QWSServerSocket(const QString &file, QObject *parent=0)
void init(const QString &file)
SocketError error() const
Returns the last error to have occurred on this object.
QByteArray toLocal8Bit() const Q_REQUIRED_RESULT
Returns the local 8-bit representation of the string as a QByteArray.
const char * constData() const
Returns a pointer to the data stored in the byte array.
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
void incomingConnection(int socketDescriptor)
#define st(var, type, card)
The QTcpServer class provides a TCP-based server.
The QUnixSocketServer class provides a Unix domain socket based server.
bool connect(const QByteArray &path)
Attempt to connect to path.
ServerError
The ServerError enumeration represents the errors that can occur during server establishment.
#define qPrintable(string)
QWSSocket * nextPendingConnection()