Index: libroar/stream.c
===================================================================
--- libroar/stream.c	(revision 5961)
+++ libroar/stream.c	(revision 6026)
@@ -299,4 +299,94 @@
 
  return 0;
+}
+
+int roar_stream_connect_to_advanced (struct roar_connection * con, struct roar_stream * s,
+                                     int version, int ask_only, uint_least32_t flags,
+                                     int socket_type, ssize_t socket_len, const void * socketaddr,
+                                     int transport_protocol, ssize_t tranport_len, const void * transportsetup,
+                                     uint16_t clientsetup_flags, struct roar_client * clientsetup) {
+ struct roar_message m;
+ char buf[80];
+ int port;
+ uint16_t tmp;
+
+ if ( con == NULL ) {
+  roar_err_set(ROAR_ERROR_FAULT);
+  return -1;
+ }
+
+ if ( transport_protocol == ROAR_PROTO_NONE && (tranport_len != -1 || transportsetup ) ) {
+  roar_err_set(ROAR_ERROR_INVAL);
+  return -1;
+ }
+
+ if ( !((s == NULL) ^ (clientsetup == NULL)) ) {
+  roar_err_set(ROAR_ERROR_INVAL);
+  return -1;
+ }
+
+ switch (version) {
+  case 0:
+    if ( transport_protocol != ROAR_PROTO_NONE || s == NULL) {
+     roar_err_set(ROAR_ERROR_INVAL);
+     return -1;
+    }
+    switch (socket_type) {
+     case ROAR_SOCKET_TYPE_TCP:
+     case ROAR_SOCKET_TYPE_UDP:
+       if ( socket_len != 6 ) {
+        roar_err_set(ROAR_ERROR_FAULT);
+        return -1;
+       }
+       snprintf(buf, sizeof(buf), "%i.%i.%i.%i",
+                ((const unsigned char*)socketaddr)[0], ((const unsigned char*)socketaddr)[1],
+                ((const unsigned char*)socketaddr)[2], ((const unsigned char*)socketaddr)[3]);
+       port = ROAR_NET2HOST16(((const uint16_t*)socketaddr)[3]);
+       if ( roar_stream_connect_to_ask(con, s, socket_type, buf, port) == -1 )
+        return -1;
+      break;
+     case ROAR_SOCKET_TYPE_DECNET:
+       if ( socket_len < 3 ) {
+        roar_err_set(ROAR_ERROR_FAULT);
+        return -1;
+       }
+       tmp  = ((const uint16_t*)socketaddr)[0];
+       port = ((const unsigned char*)socketaddr)[2];
+       snprintf(buf, sizeof(buf), "%i.%i::%*s", tmp >> 10, tmp & 0x03FF, (int)socket_len - 3, (const char*)socketaddr + 3);
+       if ( roar_stream_connect_to_ask(con, s, socket_type, buf, port) == -1 )
+        return -1;
+      break;
+     default:
+       if ( ((const char *)socketaddr)[socket_len-1] == 0 ) {
+        if ( socket_len > sizeof(buf) ) {
+         roar_err_set(ROAR_ERROR_MSGSIZE);
+         return -1;
+        }
+        memcpy(buf, socketaddr, socket_len);
+        if ( roar_stream_connect_to_ask(con, s, socket_type, buf, 0) == -1 )
+         return -1;
+       } else {
+        roar_err_set(ROAR_ERROR_FAULT);
+        return -1;
+       }
+      break;
+    }
+   break;
+  default:
+    roar_err_set(ROAR_ERROR_NSVERSION);
+    return -1;
+   break;
+ }
+
+
+ if ( ask_only )
+  return 0;
+
+ if ( roar_recv_message(con, &m, NULL) == -1 )
+  return -1;
+
+ if ( m.cmd == ROAR_CMD_OK )
+  return 0;
+ return -1;
 }
 
Index: libroar/vio_stream.c
===================================================================
--- libroar/vio_stream.c	(revision 6023)
+++ libroar/vio_stream.c	(revision 6026)
@@ -164,4 +164,7 @@
  int    opt  = 1;
 #endif
+#ifdef ROAR_HAVE_LIBDNET
+ struct dn_naddr      *binaddr;
+#endif
 #ifdef ROAR_HAVE_IPV4
  struct sockaddr_in   socket_addr;
@@ -181,4 +184,6 @@
 #endif
  struct roar_sockname sockname;
+ char socketaddr[80];
+ ssize_t socketaddr_len = -1;
 
  // make valgrind happy
@@ -214,19 +219,38 @@
 
  if ( sockname.type == ROAR_SOCKET_TYPE_DECNET ) {
-  if ( roar_socket_get_local_nodename() ) {
-   snprintf(file, sizeof(file), "%s::roar$TMP%04x%02x", roar_socket_get_local_nodename(), getpid(), count++);
+#ifdef ROAR_HAVE_LIBDNET
+  if ( roar_socket_get_local_nodename() != NULL && (binaddr = getnodeadd()) != NULL ) {
+   snprintf(socketaddr+3, sizeof(socketaddr)-3, "roar$TMP%04x%02x", getpid(), count++);
+   snprintf(file, sizeof(file), "%s::%s", roar_socket_get_local_nodename(), socketaddr+3);
+   memcpy(socketaddr, binaddr->a_addr, 2);
+   socketaddr[2] = 0; // object 0.
+   socketaddr_len = 3 + roar_mm_strlen(socketaddr+3);
   } else {
    return -1;
   }
+#else
+  roar_err_set(ROAR_ERROR_NOSYS);
+  return -1;
+#endif
 #ifdef ROAR_HAVE_IPV4
  } else {
-  strncpy(file, inet_ntoa(socket_addr.sin_addr), sizeof(file) - 1);
+  strncpy(file, sockname.addr, sizeof(file) - 1);
+  roar_err_set(ROAR_ERROR_NONE);
+  if ( inet_aton(sockname.addr, &socket_addr.sin_addr) == 0 ) {
+   roar_err_update();
+   return -1;
+  }
+  memcpy(socketaddr, &socket_addr.sin_addr.s_addr, 4);
+  socketaddr_len = 6;
 #endif
  }
 
  if ( sockname.type != ROAR_SOCKET_TYPE_UNIX ) {
+  roar_libroar_nowarn();
   if ( (listen = roar_socket_listen(sockname.type, file, port)) == -1 ) {
+   roar_libroar_warn();
    return -1;
   }
+  roar_libroar_warn();
  }
 
@@ -239,4 +263,5 @@
    return -1;
   }
+  ((uint16_t*)socketaddr)[3] = socket_addr.sin_port;
   port = ROAR_NET2HOST16(socket_addr.sin_port);
   ROAR_DBG("roar_simple_new_stream_obj(*): port=%i", port);
@@ -262,5 +287,5 @@
  if ( sockname.type != ROAR_SOCKET_TYPE_UNIX ) {
 #ifdef ROAR_HAVE_SELECT
-  if ( roar_stream_connect_to_ask(con, s, sockname.type, file, port) != -1 ) {
+  if ( roar_stream_connect_to_advanced(con, s, 0, 1, 0, sockname.type, socketaddr_len, socketaddr, ROAR_PROTO_NONE, -1, NULL, 0, NULL) != -1 ) {
 
    FD_ZERO(&fds);
@@ -334,4 +359,5 @@
   close(listen);
 #else
+  roar_err_set(ROAR_ERROR_NOSYS);
   return -1;
 #endif
