Index: libroar/error.c
===================================================================
--- libroar/error.c	(revision 5183)
+++ libroar/error.c	(revision 5184)
@@ -920,5 +920,5 @@
   {ROAR_ERROR_NONE,        "No error"},
   {ROAR_ERROR_PERM,        "Operation not permitted"},
-  {ROAR_ERROR_NOENT,       "No such object, file or directory"},
+  {ROAR_ERROR_NOENT,       "No such object, file, directory or node"},
   {ROAR_ERROR_BADMSG,      "Bad message"},
   {ROAR_ERROR_BUSY,        "Device or resource busy"},
Index: libroar/socket.c
===================================================================
--- libroar/socket.c	(revision 5148)
+++ libroar/socket.c	(revision 5184)
@@ -498,4 +498,6 @@
 #ifdef ROAR_HAVE_IPX
 #define _NEED_OBJ
+#endif
+#if defined(ROAR_HAVE_IPX) || defined(ROAR_HAVE_GETADDRINFO)
  int ret;
 #endif
@@ -551,4 +553,6 @@
 
  ROAR_DBG("roar_socket_open(mode=%i, type=%i, host='%s', port=%i) = ?", mode, type, host, port);
+
+ roar_err_set(ROAR_ERROR_UNKNOWN);
 
  if ( mode == MODE_LISTEN )
@@ -588,4 +592,5 @@
    if ( del == NULL ) {
     ROAR_WARN("roar_socket_open(*): invalid hostname for DECnet: %s", host);
+    roar_err_set(ROAR_ERROR_INVAL);
     return -1;
    }
@@ -610,5 +615,4 @@
    *del = ':';
    return fh;
-//   return -1; // listen sockets on DECnet are not supportet at the moment
   } else {
    // There is nothing wrong in this case to use dnet_conn() so we do.
@@ -620,4 +624,5 @@
   }
 #else
+  roar_err_set(ROAR_ERROR_AFNOTSUP);
   return -1; // no decnet support
 #endif
@@ -660,5 +665,23 @@
   snprintf(port_as_string, sizeof(port_as_string), "%i", port);
 
-  if ( getaddrinfo(host, port_as_string, &hints, &res) != 0 )
+  ret = getaddrinfo(host, port_as_string, &hints, &res);
+  switch (ret) {
+   case 0: /* no error */; break;
+   case EAI_ADDRFAMILY: roar_err_set(ROAR_ERROR_NOENT);    break;
+   case EAI_AGAIN:      roar_err_set(ROAR_ERROR_AGAIN);    break;
+   case EAI_BADFLAGS:   roar_err_set(ROAR_ERROR_INVAL);    break;
+   case EAI_FAIL:       roar_err_set(ROAR_ERROR_RIO);      break;
+   case EAI_FAMILY:     roar_err_set(ROAR_ERROR_AFNOTSUP); break;
+   case EAI_MEMORY:     roar_err_set(ROAR_ERROR_NOMEM);    break;
+   case EAI_NODATA:     roar_err_set(ROAR_ERROR_NODATA);   break;
+   case EAI_NONAME:     roar_err_set(ROAR_ERROR_NOENT);    break;
+   case EAI_SERVICE:    roar_err_set(ROAR_ERROR_PROTONOSUP); break;
+   case EAI_SOCKTYPE:   roar_err_set(ROAR_ERROR_INVAL);    break;
+   case EAI_SYSTEM:     roar_err_from_errno();             break;
+   default:
+     roar_err_set(ROAR_ERROR_UNKNOWN);
+    break;
+  }
+  if ( ret != 0 )
    return -1;
 
@@ -682,4 +705,5 @@
    ROAR_ERR("roar_socket_open(*): Can\'t resolve host name '%s'",
                      host);
+   roar_err_from_errno();
    return -1;
   }
@@ -710,4 +734,5 @@
    if ( mode_func(fh, (struct sockaddr *)&socket_addr.sa, addrlen) == -1 ) {
     ROAR_DBG("roar_socket_open(*): Can not connect/bind: %s", strerror(errno));
+    roar_err_from_errno();
     close(fh);
     return -1;
@@ -720,4 +745,5 @@
 #else
   ROAR_DBG("roar_socket_open(*) = -1 // no IPv4 or IPv6 support");
+  roar_err_set(ROAR_ERROR_AFNOTSUP);
   return -1;
 #endif
@@ -737,4 +763,5 @@
   if ( mode_func(fh, (struct sockaddr *)&socket_addr.un, sizeof(struct sockaddr_un)) == -1 ) {
    ROAR_DBG("roar_socket_open(*): Can not connect/bind: %s", strerror(errno));
+   roar_err_from_errno();
    close(fh);
    return -1;
@@ -742,4 +769,5 @@
 #else
   ROAR_ERR("roar_socket_open(*): There is no UNIX Domain Socket support in win32, download a real OS.");
+  roar_err_set(ROAR_ERROR_AFNOTSUP);
   return -1;
 #endif
@@ -766,6 +794,8 @@
 
   close(fh);
-  return -1;
-#else
+  roar_err_set(ROAR_ERROR_NOSYS);
+  return -1;
+#else
+  roar_err_set(ROAR_ERROR_AFNOTSUP);
   return -1;
 #endif
@@ -775,4 +805,5 @@
   return roar_socket_open_file(mode, host, port);
  } else {
+  roar_err_set(ROAR_ERROR_AFNOTSUP);
   return -1;
  }
@@ -781,8 +812,10 @@
 #if defined(ROAR_HAVE_BSDSOCKETS) || defined(ROAR_TARGET_WIN32)
   if ( listen(fh, ROAR_SOCKET_QUEUE_LEN) == -1 ) {
+   roar_err_from_errno();
    close(fh);
    return -1;
   }
 #else
+  roar_err_set(ROAR_ERROR_NOSYS);
   return -1;
 #endif
