Index: doc/man1/roarctl.1
===================================================================
--- doc/man1/roarctl.1	(revision 5159)
+++ doc/man1/roarctl.1	(revision 5838)
@@ -67,4 +67,10 @@
 
 This is not supported on all platforms.
+
+.TP
+\fBservername\fR
+This command shows the server address of the server currently connected to.
+This can be diffrent from what has given e.g. in case of special server
+names like +fork.
 
 .TP
Index: libroar/basic.c
===================================================================
--- libroar/basic.c	(revision 5832)
+++ libroar/basic.c	(revision 5838)
@@ -46,4 +46,5 @@
  int r;
  char fhstr[12];
+ size_t len;
 
  if ( !strncmp(server, "+fork=", 6) ) {
@@ -78,4 +79,10 @@
   daemonimage = "roard";
 
+ len = roar_mm_strlen(daemonimage) + 9; // 9 = '+fork=' + 'X:' + '\0'
+ con->server_name = roar_mm_malloc(len);
+ if ( con->server_name != NULL ) {
+  snprintf(con->server_name, len, "+fork=%s%s", mode == NORMAL ? "d:" : "!", daemonimage);
+ }
+
  if ( socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == -1 ) {
   roar_err_from_errno();
@@ -164,4 +171,5 @@
  int fh = -1;
  int err;
+ int ret;
 
  if ( con == NULL || server == NULL ) {
@@ -177,9 +185,13 @@
    return -1;
   con->flags |= ROAR_CON_FLAGS_VIO;
+  con->server_name = roar_mm_strdup(server);
   return 0;
  } else if ( !strcmp(server, "+fork") || !strncmp(server, "+fork=", 6) ) {
   return _start_server(con, server, type, flags, timeout);
  } else if ( !strcmp(server, "+internal") || !strncmp(server, "+internal=", 10) ) {
-  return _connect_internal(con, server, type, flags, timeout);
+  ret = _connect_internal(con, server, type, flags, timeout);
+  if ( ret == 0 )
+   con->server_name = roar_mm_strdup(server);
+  return ret;
  }
 
@@ -217,12 +229,9 @@
 
   if ( *obj == 0 ) {
-#ifdef DN_MAXOBJL
    roar_mm_strlcat(user_sock, ROAR_DEFAULT_OBJECT, sizeof(user_sock)-1);
    user_sock[sizeof(user_sock)-1] = 0;
-#else
-   ROAR_ERR("roar_connect_raw(*): size of DECnet object unknown.");
-#endif
-  }
-   ROAR_DBG("roar_connect_raw(*): user_sock='%s'", user_sock);
+  }
+
+  ROAR_DBG("roar_connect_raw(*): user_sock='%s'", user_sock);
  }
 
@@ -265,4 +274,6 @@
  }
 
+ con->server_name = roar_mm_strdup(server);
+
  roar_err_set(ROAR_ERROR_NONE);
  return 0;
@@ -449,9 +460,4 @@
   return -1;
 
- // TODO: this should be moved to be within _connect_server() so it also stores server names of auto located servers.
- if ( server != NULL ) {
-  con->server_name = roar_mm_strdup(server);
- }
-
  return 0;
 }
Index: libroar/config.c
===================================================================
--- libroar/config.c	(revision 5833)
+++ libroar/config.c	(revision 5838)
@@ -36,4 +36,6 @@
 #include "libroar.h"
 
+#define LEN_AUTHFILE 1024
+
 static struct roar_libroar_config_codec *
            roar_libroar_config_codec_get_conf(int32_t codec, int create, struct roar_libroar_config * config);
@@ -43,5 +45,5 @@
  static struct roar_libroar_config config;
  static int    inited = 0;
- static char   authfile[1024];
+ static char   authfile[LEN_AUTHFILE];
  const  char * home = roar_env_get_home(0);
 
@@ -102,4 +104,12 @@
   config->codecs.num = 0;
  }
+
+ if ( config->x11.display != NULL )
+  roar_mm_free(config->x11.display);
+ config->x11.display = NULL;
+
+ if ( config->daemonimage != NULL )
+  roar_mm_free(config->daemonimage);
+ config->daemonimage = NULL;
 
  return 0;
@@ -308,10 +318,14 @@
     roar_libroar_set_server(v);
   } else if ( !strcmp(k, "set-authfile") ) {
-   strncpy(config->authfile, v, 1023);
-   config->authfile[1023] = 0;
+   strncpy(config->authfile, v, LEN_AUTHFILE-1);
+   config->authfile[LEN_AUTHFILE-1] = 0;
   } else if ( !strcmp(k, "x11-display") ) {
-   config->x11.display = v;
+   if ( config->x11.display != NULL )
+    roar_mm_free(config->x11.display);
+   config->x11.display = roar_mm_strdup(v);
   } else if ( !strcmp(k, "daemonimage") ) {
-   config->daemonimage = v;
+   if ( config->daemonimage != NULL )
+    roar_mm_free(config->daemonimage);
+   config->daemonimage = roar_mm_strdup(v);
   } else if ( !strcmp(k, "serverflags") ) {
    if ( !strcmp(v, "nonblock") ) {
Index: roarclients/roarctl.c
===================================================================
--- roarclients/roarctl.c	(revision 5837)
+++ roarclients/roarctl.c	(revision 5838)
@@ -78,4 +78,5 @@
         "  ping  NUM               - Do NUM pings using NOOP commands\n"
 #endif
+        "  servername              - Show name of server currently connected to\n"
         "  whoami                  - Get own client ID\n"
         "\n"
@@ -1272,4 +1273,6 @@
     i++;
 #endif
+  } else if ( !strcmp(k, "servername") ) {
+   printf("Server Name           : %s\n", roar_get_connection_server(&con));
 
   } else if ( !strcmp(k, "standby") || !strcmp(k, "off") ) {
