Index: /trunk/src/network/socket/qlocalserver.cpp
===================================================================
--- /trunk/src/network/socket/qlocalserver.cpp	(revision 754)
+++ /trunk/src/network/socket/qlocalserver.cpp	(revision 755)
@@ -201,5 +201,7 @@
     Usually you would just pass in a name like "foo", but on Unix this
     could also be a path such as "/tmp/foo" and on Windows this could
-    be a pipe path such as "\\\\.\\pipe\\foo"
+    be a pipe path such as "\\\\.\\pipe\\foo". On OS/2, "\\socket\\" is
+    automatically prepended to the name if it does not already sttart with
+    this prefix.
 
     Note:
@@ -298,6 +300,6 @@
     instance has not been cleaned up.
 
-    On Windows, this function does nothing; on Unix, it removes the socket file
-    given by \a name.
+    On Windows and OS/2, this function does nothing; on Unix, it removes the
+    socket file given by \a name.
 
     \warning Be careful to avoid removing sockets of running instances.
Index: /trunk/src/network/socket/qlocalserver_os2.cpp
===================================================================
--- /trunk/src/network/socket/qlocalserver_os2.cpp	(revision 754)
+++ /trunk/src/network/socket/qlocalserver_os2.cpp	(revision 755)
@@ -64,15 +64,6 @@
 bool QLocalServerPrivate::removeServer(const QString &name)
 {
-    QString fileName;
-    if (name.startsWith(QLatin1Char('/'))) {
-        fileName = name;
-    } else {
-        fileName = QDir::cleanPath(QDir::tempPath());
-        fileName += QLatin1Char('/') + name;
-    }
-    if (QFile::exists(fileName))
-        return QFile::remove(fileName);
-    else
-        return true;
+    Q_UNUSED(name);
+    return true;
 }
 
@@ -81,10 +72,11 @@
     Q_Q(QLocalServer);
 
+    // Local OS/2 sockets must always start with "\socket\"
+    const QLatin1String socketPath("\\socket\\");
+
     // determine the full server path
-    if (requestedServerName.startsWith(QLatin1Char('/'))) {
-        fullServerName = requestedServerName;
-    } else {
-        fullServerName = QDir::cleanPath(QDir::tempPath());
-        fullServerName += QLatin1Char('/') + requestedServerName;
+    fullServerName = QDir::toNativeSeparators(requestedServerName);
+    if (!fullServerName.startsWith(socketPath)) {
+        fullServerName = socketPath + requestedServerName;
     }
     serverName = requestedServerName;
@@ -101,11 +93,13 @@
     struct ::sockaddr_un addr;
     addr.sun_family = PF_UNIX;
-    if (sizeof(addr.sun_path) < (uint)fullServerName.toLatin1().size() + 1) {
-        setError(QLatin1String("QLocalServer::listen"));
-        closeServer();
-        return false;
-    }
-    ::memcpy(addr.sun_path, fullServerName.toLatin1().data(),
-             fullServerName.toLatin1().size() + 1);
+    addr.sun_len = sizeof(sockaddr_un);
+    QByteArray fsn = fullServerName.toLocal8Bit();
+    if (sizeof(addr.sun_path) < (uint)fsn.size() + 1) {
+        errno = E2BIG; // indicate buffer overflow
+        setError(QLatin1String("QLocalServer::listen"));
+        closeServer();
+        return false;
+    }
+    ::strcpy(addr.sun_path, fsn);
 
     // bind
@@ -127,6 +121,4 @@
         closeServer();
         listenSocket = -1;
-        if (error != QAbstractSocket::AddressInUseError)
-            QFile::remove(fullServerName);
         return false;
     }
@@ -151,7 +143,4 @@
         socketNotifier = 0;
     }
-
-    if (!fullServerName.isEmpty())
-        QFile::remove(fullServerName);
 }
 
Index: /trunk/src/network/socket/qlocalsocket.cpp
===================================================================
--- /trunk/src/network/socket/qlocalsocket.cpp	(revision 754)
+++ /trunk/src/network/socket/qlocalsocket.cpp	(revision 755)
@@ -53,5 +53,6 @@
     \brief The QLocalSocket class provides a local socket.
 
-    On Windows this is a named pipe and on Unix this is a local domain socket.
+    On Windows this is a named pipe, on Unix and OS/2 this is a local domain
+    socket.
 
     If an error occurs, socketError() returns the type of error, and
Index: /trunk/src/network/socket/qlocalsocket_os2.cpp
===================================================================
--- /trunk/src/network/socket/qlocalsocket_os2.cpp	(revision 754)
+++ /trunk/src/network/socket/qlocalsocket_os2.cpp	(revision 755)
@@ -271,21 +271,24 @@
     QString connectingPathName;
 
+    // Local OS/2 sockets must always start with "\socket\"
+    const QLatin1String socketPath("\\socket\\");
+
     // determine the full server path
-    if (connectingName.startsWith(QLatin1Char('/'))) {
-        connectingPathName = connectingName;
-    } else {
-        connectingPathName = QDir::tempPath();
-        connectingPathName += QLatin1Char('/') + connectingName;
+    connectingPathName = QDir::toNativeSeparators(connectingName);
+    if (!connectingName.startsWith(socketPath)) {
+        connectingPathName = socketPath + connectingName;
     }
 
     struct sockaddr_un name;
     name.sun_family = PF_UNIX;
-    if (sizeof(name.sun_path) < (uint)connectingPathName.toLatin1().size() + 1) {
+    name.sun_len = sizeof(sockaddr_un);
+    QByteArray cpn = connectingPathName.toLocal8Bit();
+    if (sizeof(name.sun_path) < (uint)cpn.size() + 1) {
         QString function = QLatin1String("QLocalSocket::connectToServer");
         errorOccurred(QLocalSocket::ServerNotFoundError, function);
         return;
     }
-    ::memcpy(name.sun_path, connectingPathName.toLatin1().data(),
-             connectingPathName.toLatin1().size() + 1);
+    ::strcpy(name.sun_path, cpn);
+
     if (-1 == ::connect(connectingSocket, (struct sockaddr *)&name, sizeof(name))) {
         QString function = QLatin1String("QLocalSocket::connectToServer");
