Index: /trunk/include/iprt/localipc.h
===================================================================
--- /trunk/include/iprt/localipc.h	(revision 58296)
+++ /trunk/include/iprt/localipc.h	(revision 58297)
@@ -77,6 +77,8 @@
 /** The server can handle multiple sessions. */
 #define RTLOCALIPC_FLAGS_MULTI_SESSION      RT_BIT_32(0)
+/** Native name, as apposed to a portable one. */
+#define RTLOCALIPC_FLAGS_NATIVE_NAME        RT_BIT_32(1)
 /** The mask of valid flags. */
-#define RTLOCALIPC_FLAGS_VALID_MASK         UINT32_C(0x00000001)
+#define RTLOCALIPC_FLAGS_VALID_MASK         UINT32_C(0x00000003)
 /** @} */
 
@@ -124,7 +126,15 @@
  * @param   phSession           Where to store the sesson handle on success.
  * @param   pszName             The server name (see RTLocalIpcServerCreate for details).
- * @param   fFlags              Flags. Current undefined, pass 0.
+ * @param   fFlags              Flags, RTLOCALIPC_C_FLAGS_XXX.
  */
 RTDECL(int) RTLocalIpcSessionConnect(PRTLOCALIPCSESSION phSession, const char *pszName, uint32_t fFlags);
+
+/** @name RTLOCALIPC_C_FLAGS_XXX - RTLocalIpcSessionConnect flags
+ * @{ */
+/** Native name, as apposed to a portable one. */
+#define RTLOCALIPC_C_FLAGS_NATIVE_NAME      RT_BIT_32(0)
+/** The mask of valid flags. */
+#define RTLOCALIPC_C_FLAGS_VALID_MASK       UINT32_C(0x00000001)
+/** @} */
 
 
Index: /trunk/src/VBox/Runtime/r3/posix/localipc-posix.cpp
===================================================================
--- /trunk/src/VBox/Runtime/r3/posix/localipc-posix.cpp	(revision 58296)
+++ /trunk/src/VBox/Runtime/r3/posix/localipc-posix.cpp	(revision 58297)
@@ -55,4 +55,5 @@
 
 #include "internal/magics.h"
+#include "internal/path.h"
 #include "internal/socket.h"
 
@@ -113,5 +114,5 @@
 
 
-/** Local IPC name prefix. */
+/** Local IPC name prefix for portable names. */
 #define RTLOCALIPC_POSIX_NAME_PREFIX    "/tmp/.iprt-localipc-"
 
@@ -122,27 +123,29 @@
  * @returns IPRT status code.
  * @param   pszName             The name to validate.
- * @param   pcchName            Where to return the length.
- */
-static int rtLocalIpcPosixValidateName(const char *pszName, size_t *pcchName)
+ * @param   fNative             Whether it's a native name or a portable name.
+ */
+static int rtLocalIpcPosixValidateName(const char *pszName, bool fNative)
 {
     AssertPtrReturn(pszName, VERR_INVALID_POINTER);
-
-    uint32_t cchName = 0;
-    for (;;)
+    AssertReturn(*pszName, VERR_INVALID_NAME);
+
+    if (!fNative)
     {
-        char ch = pszName[cchName];
-        if (!ch)
-            break;
-        AssertReturn(!RT_C_IS_CNTRL(ch), VERR_INVALID_NAME);
-        AssertReturn((unsigned)ch < 0x80, VERR_INVALID_NAME);
-        AssertReturn(ch != '\\', VERR_INVALID_NAME);
-        AssertReturn(ch != '/', VERR_INVALID_NAME);
-        cchName++;
+        for (;;)
+        {
+            char ch = *pszName++;
+            if (!ch)
+                break;
+            AssertReturn(!RT_C_IS_CNTRL(ch), VERR_INVALID_NAME);
+            AssertReturn((unsigned)ch < 0x80, VERR_INVALID_NAME);
+            AssertReturn(ch != '\\', VERR_INVALID_NAME);
+            AssertReturn(ch != '/', VERR_INVALID_NAME);
+        }
     }
-
-    *pcchName = cchName;
-    AssertReturn(sizeof(RTLOCALIPC_POSIX_NAME_PREFIX) + cchName <= RT_SIZEOFMEMB(struct sockaddr_un, sun_path),
-                 VERR_FILENAME_TOO_LONG);
-    AssertReturn(cchName, VERR_INVALID_NAME);
+    else
+    {
+        int rc = RTStrValidateEncoding(pszName);
+        AssertRCReturn(rc, rc);
+    }
 
     return VINF_SUCCESS;
@@ -157,28 +160,40 @@
  * @param   pcbAddr             Where to return the address size.
  * @param   pszName             The user specified name (valid).
- * @param   cchName             The user specified name length.
- */
-static int rtLocalIpcPosixConstructName(struct sockaddr_un *pAddr, uint8_t *pcbAddr, const char *pszName, size_t cchName)
-{
-    AssertMsgReturn(cchName + sizeof(RTLOCALIPC_POSIX_NAME_PREFIX) <= sizeof(pAddr->sun_path),
-                    ("cchName=%zu sizeof(sun_path)=%zu\n", cchName, sizeof(pAddr->sun_path)),
-                    VERR_FILENAME_TOO_LONG);
-
-/** @todo Bother converting to local codeset/encoding??  */
-
-    RT_ZERO(*pAddr);
+ * @param   fNative             Whether it's a native name or a portable name.
+ */
+static int rtLocalIpcPosixConstructName(struct sockaddr_un *pAddr, uint8_t *pcbAddr, const char *pszName, bool fNative)
+{
+    const char *pszNativeName;
+    int rc = rtPathToNative(&pszNativeName, pszName, NULL /*pszBasePath not support*/);
+    if (RT_SUCCESS(rc))
+    {
+        size_t cchNativeName = strlen(pszNativeName);
+        size_t cbFull = !fNative ? cchNativeName + sizeof(RTLOCALIPC_POSIX_NAME_PREFIX) : cchNativeName + 1;
+        if (cbFull <= sizeof(pAddr->sun_path))
+        {
+            RT_ZERO(*pAddr);
 #ifdef RT_OS_OS2 /* Size must be exactly right on OS/2. */
-    *pcbAddr = sizeof(*pAddr);
+            *pcbAddr = sizeof(*pAddr);
 #else
-    *pcbAddr = RT_OFFSETOF(struct sockaddr_un, sun_path) + (uint8_t)cchName + sizeof(RTLOCALIPC_POSIX_NAME_PREFIX);
+            *pcbAddr = RT_OFFSETOF(struct sockaddr_un, sun_path) + (uint8_t)cbFull;
 #endif
 #ifdef HAVE_SUN_LEN_MEMBER
-    pAddr->sun_len     = *pcbAddr;
+            pAddr->sun_len     = *pcbAddr;
 #endif
-    pAddr->sun_family  = AF_LOCAL;
-    memcpy(pAddr->sun_path, RTLOCALIPC_POSIX_NAME_PREFIX, sizeof(RTLOCALIPC_POSIX_NAME_PREFIX) - 1);
-    memcpy(&pAddr->sun_path[sizeof(RTLOCALIPC_POSIX_NAME_PREFIX) - 1], pszName, cchName + 1);
-
-    return VINF_SUCCESS;
+            pAddr->sun_family  = AF_LOCAL;
+
+            if (!fNative)
+            {
+                memcpy(pAddr->sun_path, RTLOCALIPC_POSIX_NAME_PREFIX, sizeof(RTLOCALIPC_POSIX_NAME_PREFIX) - 1);
+                memcpy(&pAddr->sun_path[sizeof(RTLOCALIPC_POSIX_NAME_PREFIX) - 1], pszNativeName, cchNativeName + 1);
+            }
+            else
+                memcpy(pAddr->sun_path, pszNativeName, cchNativeName + 1);
+        }
+        else
+            rc = VERR_FILENAME_TOO_LONG;
+        rtPathFreeNative(pszNativeName, pszName);
+    }
+    return rc;
 }
 
@@ -195,6 +210,5 @@
     AssertReturn(!(fFlags & ~RTLOCALIPC_FLAGS_VALID_MASK), VERR_INVALID_FLAGS);
 
-    size_t cchName;
-    int rc = rtLocalIpcPosixValidateName(pszName, &cchName);
+    int rc = rtLocalIpcPosixValidateName(pszName, RT_BOOL(fFlags & RTLOCALIPC_FLAGS_NATIVE_NAME));
     if (RT_SUCCESS(rc))
     {
@@ -222,5 +236,6 @@
 
                     uint8_t cbAddr;
-                    rc = rtLocalIpcPosixConstructName(&pThis->Name, &cbAddr, pszName, cchName);
+                    rc = rtLocalIpcPosixConstructName(&pThis->Name, &cbAddr, pszName,
+                                                      RT_BOOL(fFlags & RTLOCALIPC_FLAGS_NATIVE_NAME));
                     if (RT_SUCCESS(rc))
                     {
@@ -475,8 +490,7 @@
     *phSession = NIL_RTLOCALIPCSESSION;
 
-    AssertReturn(!fFlags, VERR_INVALID_FLAGS);
-
-    size_t cchName;
-    int rc = rtLocalIpcPosixValidateName(pszName, &cchName);
+    AssertReturn(!(fFlags & ~RTLOCALIPC_C_FLAGS_VALID_MASK), VERR_INVALID_FLAGS);
+
+    int rc = rtLocalIpcPosixValidateName(pszName, RT_BOOL(fFlags & RTLOCALIPC_C_FLAGS_NATIVE_NAME));
     if (RT_SUCCESS(rc))
     {
@@ -507,5 +521,5 @@
                     struct sockaddr_un  Addr;
                     uint8_t             cbAddr;
-                    rc = rtLocalIpcPosixConstructName(&Addr, &cbAddr, pszName, cchName);
+                    rc = rtLocalIpcPosixConstructName(&Addr, &cbAddr, pszName, RT_BOOL(fFlags & RTLOCALIPC_C_FLAGS_NATIVE_NAME));
                     if (RT_SUCCESS(rc))
                     {
