Index: include/libroar/roarfeatures.h
===================================================================
--- include/libroar/roarfeatures.h	(revision 5010)
+++ include/libroar/roarfeatures.h	(revision 5065)
@@ -48,4 +48,5 @@
 #define ROAR_FT_FUNC_PANIC
 #define ROAR_FT_FUNC_RESET
+#define ROAR_FT_FUNC_CLOCK_GETTIME
 #define ROAR_FT_FEATURE_VS
 #define ROAR_FT_FEATURE_VS_FILE
Index: include/libroar/roartime.h
===================================================================
--- include/libroar/roartime.h	(revision 5031)
+++ include/libroar/roartime.h	(revision 5065)
@@ -51,4 +51,6 @@
 int roar_get_time  (struct roar_connection * con, struct roar_time * time);
 
+int roar_clock_gettime(struct roar_time * rt, int clock);
+
 #endif
 
Index: include/roaraudio/proto.h
===================================================================
--- include/roaraudio/proto.h	(revision 5031)
+++ include/roaraudio/proto.h	(revision 5065)
@@ -195,4 +195,11 @@
 #define ROAR_ITST_UIURL             10
 
+// IDs for diffrent clocks:
+#define ROAR_CLOCK_DEFAULT          -2
+#define ROAR_CLOCK_UNKNOWN          -1
+#define ROAR_CLOCK_REALTIME          1
+#define ROAR_CLOCK_MONOTONIC         2
+#define ROAR_CLOCK_UPTIME            3
+
 // old: do not use.
 struct roar_timeofday {
Index: libroar/time.c
===================================================================
--- libroar/time.c	(revision 5031)
+++ libroar/time.c	(revision 5065)
@@ -57,9 +57,9 @@
 
  if ( time->c_drift == 0 ) {
-  mes->datalen -= 4;
+  mes->datalen -= 8;
   if ( time->c_freq == 0 ) {
-   mes->datalen -= 4;
+   mes->datalen -= 8;
    if ( time->t_ssec == 0 ) {
-    mes->datalen -= 4;
+    mes->datalen -= 8;
    }
   }
@@ -140,3 +140,46 @@
 }
 
+int roar_clock_gettime(struct roar_time * rt, int clock) {
+#ifdef ROAR_HAVE_GETTIMEOFDAY
+ struct timeval tv;
+#elif defined(ROAR_HAVE_TIME)
+ time_t now;
+#endif
+
+ if ( rt == NULL ) {
+  roar_err_set(ROAR_ERROR_FAULT);
+  return -1;
+ }
+
+ memset(rt, 0, sizeof(struct roar_time));
+
+ if ( clock == ROAR_CLOCK_DEFAULT )
+  clock = ROAR_CLOCK_REALTIME;
+
+ switch (clock) {
+  case ROAR_CLOCK_REALTIME:
+#ifdef ROAR_HAVE_GETTIMEOFDAY
+    if ( gettimeofday(&tv, NULL) == -1 ) {
+     roar_err_from_errno();
+     return -1;
+    }
+    rt->t_sec  = tv.tv_sec;
+    rt->t_ssec = (uint64_t)tv.tv_usec * (uint64_t)18446744073709ULL;
+    rt->c_freq = 1000LLU;
+#elif defined(ROAR_HAVE_TIME)
+    now = time(NULL);
+    rt->t_sec  = now;
+    rt->c_freq = 1000000000LLU;
+#else
+    roar_err_set(ROAR_ERROR_NOTSUP);
+    return -1;
+#endif
+    return 0;
+   break;
+ }
+
+ roar_err_set(ROAR_ERROR_NOTSUP);
+ return -1;
+}
+
 //ll
Index: roarclients/roarctl.c
===================================================================
--- roarclients/roarctl.c	(revision 5031)
+++ roarclients/roarctl.c	(revision 5065)
@@ -249,5 +249,5 @@
 
  if ( roar_get_time(con, &time) == -1 ) {
-  fprintf(stderr, "Error: can not get server time\n");
+  fprintf(stderr, "Error: can not get server time: %s\n", roar_error2str(roar_error));
   return;
  }
Index: roard/req.c
===================================================================
--- roard/req.c	(revision 5031)
+++ roard/req.c	(revision 5065)
@@ -683,11 +683,5 @@
 
 int req_on_gettimeofday (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) {
-#if defined(ROAR_HAVE_GETTIMEOFDAY) || defined(ROAR_HAVE_TIME)
  struct roar_time curtime;
-#ifdef ROAR_HAVE_GETTIMEOFDAY
- struct timeval tv;
-#elif defined(ROAR_HAVE_TIME)
- time_t now = time(NULL);
-#endif
 
  ROAR_DBG("req_on_gettimeofday(client=%i, mes=%p, data=%p, flags=%p) = ?", client, mes, data, flags);
@@ -713,14 +707,6 @@
  ROAR_DBG("req_on_gettimeofday(client=%i, mes=%p, data=%p, flags=%p) = ?", client, mes, data, flags);
 
- memset(&curtime, 0, sizeof(curtime));
-
-#ifdef ROAR_HAVE_GETTIMEOFDAY
- if ( gettimeofday(&tv, NULL) == -1 )
-  return -1;
- curtime.t_sec  = tv.tv_sec;
- curtime.t_ssec = (uint64_t)tv.tv_usec * (uint64_t)18446744073709ULL;
-#elif defined(ROAR_HAVE_TIME)
- curtime.t_sec = now;
-#endif
+ if ( roar_clock_gettime(&curtime, ROAR_CLOCK_REALTIME) == -1 )
+  return -1;
 
  if ( roar_time_to_msg(mes, &curtime) == -1 )
@@ -732,7 +718,4 @@
 
  return 0;
-#else
- return -1;
-#endif
 }
 
