Index: ChangeLog
===================================================================
--- ChangeLog	(revision 4803)
+++ ChangeLog	(revision 4806)
@@ -1,2 +1,6 @@
+v. 0.4beta5 - ?
+	* Started with support for non-blocking server locating attempts.
+	* Speed up SLP lookup without DA by about 6 sec.
+
 v. 0.4beta4 - Sun Mar 20 2011 12:15 CET
 	Prereleases: 0: Thu Feb 24 2011 27:36 CET;
Index: include/libroar/basic.h
===================================================================
--- include/libroar/basic.h	(revision 4708)
+++ include/libroar/basic.h	(revision 4806)
@@ -77,6 +77,8 @@
 
 int roar_connect_raw  (char * server);
+int roar_connect_raw2 (char * server, int flags, uint_least32_t timeout);
 
 int roar_connect      (struct roar_connection * con, char * server);
+int roar_connect2     (struct roar_connection * con, char * server, int flags, uint_least32_t timeout);
 int roar_connect_fh   (struct roar_connection * con, int fh);
 int roar_get_connection_fh  (struct roar_connection * con);
Index: include/libroar/simple.h
===================================================================
--- include/libroar/simple.h	(revision 4708)
+++ include/libroar/simple.h	(revision 4806)
@@ -40,4 +40,5 @@
 
 int roar_simple_connect (struct roar_connection * con, char * server, char * name);
+int roar_simple_connect2(struct roar_connection * con, char * server, char * name, int flags, uint_least32_t timeout);
 
 int roar_simple_stream  (int rate, int channels, int bits, int codec, char * server, int dir, char * name);
Index: libroar/basic.c
===================================================================
--- libroar/basic.c	(revision 4780)
+++ libroar/basic.c	(revision 4806)
@@ -37,4 +37,8 @@
 
 int roar_connect_raw (char * server) {
+ return roar_connect_raw2(server, 0, 0);
+}
+
+int roar_connect_raw2 (char * server, int flags, uint_least32_t timeout) {
 #ifdef ROAR_HAVE_LIBSLP
  struct roar_libroar_config * config = roar_libroar_get_config();
@@ -56,6 +60,17 @@
  struct roar_x11_connection * x11con;
 #endif
+ struct roar_server * list;
+ int workarounds_store;
 
  roar_errno = ROAR_ERROR_UNKNOWN;
+
+ if ( timeout != 0 ) {
+  roar_errno = ROAR_ERROR_INVAL;
+  return -1;
+ }
+
+ if ( flags & ROAR_ENUM_FLAG_HARDNONBLOCK )
+  flags |= ROAR_ENUM_FLAG_NONBLOCK;
+
 
  if ( server == NULL )
@@ -136,15 +151,32 @@
 
 #ifdef ROAR_HAVE_LIBSLP
- if ( !(config->workaround.workarounds & ROAR_LIBROAR_CONFIG_WAS_NO_SLP) ) {
-  if ( (server = roar_slp_find_roard(0)) != NULL )
+ if ( !(config->workaround.workarounds & ROAR_LIBROAR_CONFIG_WAS_NO_SLP) &&
+      !(flags & ROAR_ENUM_FLAG_NONBLOCK)
+    ) {
+  if ( (server = roar_slp_find_roard(0)) != NULL ) {
    if ( (fh = roar_connect_raw(server)) != -1 )
     return fh;
 
-  /* in case we can not connect to the server given this may be a cache problem,
-     we do a new lookup with the cache disabled in this case                     */
-  ROAR_WARN("roar_connect_raw(*): Can not connect to SLP located server, disabling cache");
-  if ( (server = roar_slp_find_roard(1)) != NULL )
-   if ( (fh = roar_connect_raw(server)) != -1 )
+   /* in case we can not connect to the server given this may be a cache problem,
+      we do a new lookup with the cache disabled in this case                     */
+   ROAR_WARN("roar_connect_raw(*): Can not connect to SLP located server, disabling cache");
+   if ( (server = roar_slp_find_roard(1)) != NULL )
+    if ( (fh = roar_connect_raw(server)) != -1 )
+     return fh;
+  }
+ }
+
+ workarounds_store = config->workaround.workarounds;
+ config->workaround.workarounds |= ROAR_LIBROAR_CONFIG_WAS_NO_SLP;
+ list = roar_enum_servers(flags, -1, -1);
+ config->workaround.workarounds = workarounds_store;
+ if ( list != NULL ) {
+  for (i = 0; list[i].server != NULL; i++) {
+   if ( (fh = roar_connect_raw((char*)list[i].server)) != -1 ) {
+    roar_enum_servers_free(list);
     return fh;
+   }
+  }
+  roar_enum_servers_free(list);
  }
 #endif
@@ -207,4 +239,8 @@
 
 int roar_connect    (struct roar_connection * con, char * server) {
+ return roar_connect2(con, server, 0, 0);
+}
+
+int roar_connect2     (struct roar_connection * con, char * server, int flags, uint_least32_t timeout) {
  int fh;
 
@@ -215,5 +251,5 @@
 
  roar_errno = ROAR_ERROR_UNKNOWN;
- fh = roar_connect_raw(server);
+ fh = roar_connect_raw2(server, flags, timeout);
 
  if ( fh == -1 )
Index: libroar/simple.c
===================================================================
--- libroar/simple.c	(revision 4708)
+++ libroar/simple.c	(revision 4806)
@@ -37,8 +37,12 @@
 
 int roar_simple_connect (struct roar_connection * con, char * server, char * name) {
+ return roar_simple_connect2(con, server, name, 0, 0);
+}
+
+int roar_simple_connect2(struct roar_connection * con, char * server, char * name, int flags, uint_least32_t timeout) {
 
  ROAR_DBG("roar_simple_connect(*): trying to connect...");
 
- if ( roar_connect(con, server) == -1 ) {
+ if ( roar_connect2(con, server, flags, timeout) == -1 ) {
   ROAR_DBG("roar_simple_connect(*): roar_connect() faild!");
   return -1;
