Index: include/libroar/socket.h
===================================================================
--- include/libroar/socket.h	(revision 502)
+++ include/libroar/socket.h	(revision 508)
@@ -36,8 +36,13 @@
 int roar_socket_new_udp    (void);
 int roar_socket_new_unix   (void);
+int roar_socket_new_decnet_seqpacket (void);
+int roar_socket_new_decnet_stream (void);
+
 int roar_socket_open       (int mode, int type, char * host, int port);
 int roar_socket_open_fork  (int mode, char * host, int port);
 int roar_socket_open_file  (int mode, char * host, int port);
 int roar_socket_open_proxy (int mode, int type, char * host, int port, char * proxy_type);
+
+int roar_socket_listen_decnet (char * object, int num);
 
 int roar_socket_nonblock(int fh, int state);
Index: include/roaraudio.h
===================================================================
--- include/roaraudio.h	(revision 480)
+++ include/roaraudio.h	(revision 508)
@@ -52,9 +52,16 @@
 #include <libroar/libroar.h>
 
+// IP
 #define ROAR_DEFAULT_PORT        16002
 #define ROAR_DEFAULT_HOST        "localhost"
 
+// UNIX Domain Sockets
 #define ROAR_DEFAULT_SOCK_GLOBAL "/tmp/roar"
 #define ROAR_DEFAULT_SOCK_USER   ".roar"
+
+// DECnet
+#define ROAR_DEFAULT_OBJECT      "roar"
+#define ROAR_DEFAULT_NUM         0
+#define ROAR_DEFAULT_LISTEN_OBJECT "LISTEN::" ROAR_DEFAULT_OBJECT
 
 #define ROAR_DEFAULT_SOCKGRP     "audio"
@@ -118,4 +125,12 @@
 #define ROAR_HOST2NET16(x) (x)
 
+#ifdef ROAR_HAVE_LIBDNET
+#define ROAR_dn_ntohs(x) ((((x)&0x0ff)<<8) | (((x)&0xff00)>>8))
+#define ROAR_dn_ntohl(x) ( ((dn_ntohs((x)&0xffff))<<16) |\
+                           ((dn_ntohs(((x)>>16)))) )
+#define ROAR_dn_htonl(x) ROAR_dn_ntohl(x)
+#define ROAR_dn_htons(x) ROAR_dn_ntohs(x)
+#endif
+
 //#elif BYTE_ORDER == LITTLE_ENDIAN
 #else
@@ -126,4 +141,16 @@
 #define ROAR_HOST2NET16(x) htons((x))
 
+#ifdef ROAR_HAVE_LIBDNET
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define ROAR_dn_ntohs(x) (x)
+#define ROAR_dn_htons(x) (x)
+
+#define ROAR_dn_ntohl(x) (x)
+#define ROAR_dn_htonl(x) (x)
+#else
+#error can not build on this architecture with DECnet support enabled
+#endif
+#endif
+
 #endif
 
Index: libroar/socket.c
===================================================================
--- libroar/socket.c	(revision 503)
+++ libroar/socket.c	(revision 508)
@@ -42,4 +42,30 @@
  return fh;
 }
+
+int roar_socket_new_decnet_seqpacket (void) {
+#ifdef ROAR_HAVE_LIBDNET
+ int fh;
+
+ fh = socket(AF_DECnet, SOCK_SEQPACKET, DNPROTO_NSP);
+
+ return fh;
+#else
+ return -1;
+#endif
+}
+
+
+int roar_socket_new_decnet_stream (void) {
+#ifdef ROAR_HAVE_LIBDNET
+ int fh;
+
+ fh = socket(AF_DECnet, SOCK_STREAM, DNPROTO_NSP);
+
+ return fh;
+#else
+ return -1;
+#endif
+}
+
 
 int roar_socket_nonblock(int fh, int state) {
@@ -119,4 +145,51 @@
   return roar_socket_open_proxy(MODE_CONNECT, ROAR_SOCKET_TYPE_UNKNOWN, host, port, proxy_type);
  }
+}
+
+
+int roar_socket_listen_decnet (char * object, int num) {
+#ifdef ROAR_HAVE_LIBDNET
+ int fh = roar_socket_new_decnet_stream();
+ struct sockaddr_dn bind_sockaddr;
+
+ if ( fh == -1 )
+  return -1;
+
+ if ( !*object )
+  object = NULL;
+
+ if ( (object && num) || (!*object && !num) ) {
+  ROAR_WARN("roar_socket_listen_decnet(object='%s', num=%i): illegal address!", object, num);
+  close(fh);
+  return -1;
+ }
+
+ memset((void*)&bind_sockaddr, 0, sizeof(struct sockaddr_dn));
+
+ bind_sockaddr.sdn_family    = AF_DECnet;
+ bind_sockaddr.sdn_flags     = 0;
+ bind_sockaddr.sdn_objnum    = num;
+
+ if ( num ) {
+  bind_sockaddr.sdn_objnamel = 0;
+ } else {
+  bind_sockaddr.sdn_objnamel  = ROAR_dn_htons(strlen(object));
+  strcpy((char*)bind_sockaddr.sdn_objname, object); // FIXME: shouldn't we use strncpy()?
+ }
+
+ if ( bind(fh, (struct sockaddr *) &bind_sockaddr, sizeof(bind_sockaddr)) == -1 ) {
+  close(fh);
+  return -1;
+ }
+
+ if ( listen(fh, 8) == -1 ) {
+  close(fh);
+  return -1;
+ }
+
+ return fh;
+#else
+ return -1;
+#endif
 }
 
@@ -153,10 +226,14 @@
 
  if ( type == ROAR_SOCKET_TYPE_DECNET ) {
-  if ( mode == MODE_LISTEN ) {
-   return -1; // listen sockets on DECnet are not supportet at the moment
-  } else {
 #ifdef ROAR_HAVE_LIBDNET
-   // There is nothing wrong in this case to use dnet_conn() so we do.
+   ROAR_DBG("roar_socket_open(*): hostname for DECnet: host(%p)=%s", host, host);
    del = strstr(host, "::");
+   ROAR_DBG("roar_socket_open(*): hostname for DECnet: del(%p)=%s", del, del);
+
+   if ( del == NULL ) {
+    ROAR_WARN("roar_socket_open(*): invalid hostname for DECnet: %s", host);
+    return -1;
+   }
+
    *del = 0;
 
@@ -172,4 +249,11 @@
    }
 
+  if ( mode == MODE_LISTEN ) {
+   fh = roar_socket_listen_decnet(obj, port);
+   *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.
    fh = dnet_conn(host, obj, SOCK_STREAM, 0 ,0 ,0 , 0);
    *del = ':';
Index: roard/roard.c
===================================================================
--- roard/roard.c	(revision 501)
+++ roard/roard.c	(revision 508)
@@ -46,4 +46,7 @@
  printf(" -t  --tcp             - Use TCP listen socket\n"
         " -u  --unix            - Use UNIX Domain listen socket (default)\n"
+#ifdef ROAR_HAVE_LIBDNET
+        " -n  --decnet          - use DECnet listen socket\n"
+#endif
         " -p  --port            - TCP Port to bind to\n"
         " -b  --bind            - IP/Hostname to bind to\n"
@@ -92,4 +95,7 @@
  DRIVER_USERDATA_T drvinst;
  struct roar_client * self = NULL;
+#ifdef ROAR_HAVE_LIBDNET
+ char decnethost[80];
+#endif
 
  g_listen_socket = -1;
@@ -217,4 +223,13 @@
   } else if ( strcmp(k, "-u") == 0 ) {
    // ignore this case as it is the default behavor.
+  } else if ( strcmp(k, "-n") == 0 ) {
+#ifdef ROAR_HAVE_LIBDNET
+    port   = ROAR_DEFAULT_NUM;
+    strcpy(decnethost, ROAR_DEFAULT_LISTEN_OBJECT);
+    server = decnethost;
+#else
+    ROAR_ERR("No DECnet support compiled in!");
+    return 1;
+#endif
   } else if ( strcmp(k, "-G") == 0 ) {
    sock_grp  = argv[++i];
Index: roard/streams.c
===================================================================
--- roard/streams.c	(revision 495)
+++ roard/streams.c	(revision 508)
@@ -522,5 +522,5 @@
 int streams_check  (int id) {
  int fh;
- ssize_t req;
+ ssize_t req, realreq, done;
  struct roar_stream        *   s;
  struct roar_stream_server *  ss;
@@ -557,5 +557,18 @@
 
  if ( ss->codecfilter == -1 ) {
+  realreq = req;
+/*
   req = read(fh, buf, req);
+  if ( req < realreq ) { // we can do this as the stream is in nonblocking mode!
+   if ( (realreq = read(fh, buf+req, realreq-req)) > 0 )
+    req += realreq;
+  }
+*/
+  done = 0;
+  while (req > 0 && done != realreq) {
+   if ( (req = read(fh, buf+done, realreq-done)) > 0 )
+    done += req;
+  }
+  req = done;
  } else {
   req = codecfilter_read(ss->codecfilter_inst, ss->codecfilter, buf, req);
