diff --git a/src/vcl/CMakeLists.txt b/src/vcl/CMakeLists.txt
index b0a283c..e5642b5 100644
--- a/src/vcl/CMakeLists.txt
+++ b/src/vcl/CMakeLists.txt
@@ -59,7 +59,7 @@
     test_vcl_listener_server
     test_vcl_listener_client
   )
-    add_vpp_executable(${test} SOURCES ${test}.c LINK_LIBRARIES vppcom
+    add_vpp_executable(${test} SOURCES ${test}.c LINK_LIBRARIES vppcom pthread
 		       NO_INSTALL)
   endforeach()
 endif(VPP_BUILD_VCL_TESTS)
diff --git a/src/vcl/vcl_test_client.c b/src/vcl/vcl_test_client.c
index af51b66..4e61045 100644
--- a/src/vcl/vcl_test_client.c
+++ b/src/vcl/vcl_test_client.c
@@ -137,7 +137,6 @@
       FD_SET (tsock->fd, &rd_fdset);
       sidx = vppcom_session_index (tsock->fd);
       nfds = sidx > nfds ? sidx : nfds;
-//      nfds = ((tsock->fd + 1) > nfds) ? (tsock->fd + 1) : nfds;
     }
 
   nfds++;
@@ -256,10 +255,8 @@
   sock_client_main_t *scm = &sock_client_main;
   sock_test_socket_t *ctrl = &scm->ctrl_socket;
   sock_test_socket_t *tsock;
-  int tx_bytes;
-  uint32_t i, n;
-  int rv;
-  int nfds = 0;
+  int tx_bytes, rv, nfds = 0;
+  uint32_t i, n, sidx;
   fd_set wr_fdset, rd_fdset;
   fd_set _wfdset, *wfdset = &_wfdset;
   fd_set _rfdset, *rfdset = (test == SOCK_TEST_TYPE_BI) ? &_rfdset : 0;
@@ -297,7 +294,8 @@
       memset (&tsock->stats, 0, sizeof (tsock->stats));
       FD_SET (tsock->fd, &wr_fdset);
       FD_SET (tsock->fd, &rd_fdset);
-      nfds = ((tsock->fd + 1) > nfds) ? (tsock->fd + 1) : nfds;
+      sidx = vppcom_session_index (tsock->fd);
+      nfds = sidx > nfds ? sidx : nfds;
     }
 
   nfds++;
@@ -327,7 +325,7 @@
 	    continue;
 
 	  if ((test == SOCK_TEST_TYPE_BI) &&
-	      FD_ISSET (tsock->fd, rfdset) &&
+	      FD_ISSET (vppcom_session_index (tsock->fd), rfdset) &&
 	      (tsock->stats.rx_bytes < ctrl->cfg.total_bytes))
 	    {
 	      (void) vcl_test_read (tsock->fd,
@@ -335,7 +333,7 @@
 				    tsock->rxbuf_size, &tsock->stats);
 	    }
 
-	  if (FD_ISSET (tsock->fd, wfdset)
+	  if (FD_ISSET (vppcom_session_index (tsock->fd), wfdset)
 	      && (tsock->stats.tx_bytes < ctrl->cfg.total_bytes))
 	    {
 	      tx_bytes = vcl_test_write (tsock->fd, (uint8_t *) tsock->txbuf,
diff --git a/src/vcl/vcl_test_server.c b/src/vcl/vcl_test_server.c
index 7b56d49..8b8b77f 100644
--- a/src/vcl/vcl_test_server.c
+++ b/src/vcl/vcl_test_server.c
@@ -26,6 +26,7 @@
 #include <vcl/vcl_test.h>
 #include <sys/epoll.h>
 #include <vppinfra/mem.h>
+#include <pthread.h>
 
 typedef struct
 {
@@ -37,49 +38,79 @@
   sock_test_stats_t stats;
   vppcom_endpt_t endpt;
   uint8_t ip[16];
-} sock_server_conn_t;
+} vcl_test_server_conn_t;
 
 typedef struct
 {
-  uint32_t port;
+  uint16_t port;
   uint32_t address_ip6;
-  uint32_t transport_udp;
-} sock_server_cfg_t;
+  u8 proto;
+  u8 workers;
+  vppcom_endpt_t endpt;
+} vcl_test_server_cfg_t;
 
-#define SOCK_SERVER_MAX_TEST_CONN  10
-#define SOCK_SERVER_MAX_EPOLL_EVENTS 10
+#define SOCK_SERVER_MAX_TEST_CONN  16
+#define SOCK_SERVER_MAX_EPOLL_EVENTS 16
+
 typedef struct
 {
+  uint32_t wrk_index;
   int listen_fd;
-  sock_server_cfg_t cfg;
   int epfd;
-  struct epoll_event listen_ev;
   struct epoll_event wait_events[SOCK_SERVER_MAX_EPOLL_EVENTS];
-  size_t num_conn;
   size_t conn_pool_size;
-  sock_server_conn_t *conn_pool;
+  vcl_test_server_conn_t *conn_pool;
   int nfds;
-  fd_set rd_fdset;
-  fd_set wr_fdset;
-  struct timeval timeout;
-} sock_server_main_t;
+  pthread_t thread_handle;
+} vcl_test_server_worker_t;
 
-sock_server_main_t sock_server_main;
+typedef struct
+{
+  vcl_test_server_cfg_t cfg;
+  vcl_test_server_worker_t *workers;
+
+  struct sockaddr_storage servaddr;
+  volatile int worker_fails;
+  volatile int active_workers;
+} vcl_test_server_main_t;
+
+static __thread int __wrk_index = 0;
+
+static vcl_test_server_main_t sock_server_main;
+
+#define vtfail(_fn, _rv)						\
+{									\
+  errno = -_rv;								\
+  perror ("ERROR when calling " _fn);					\
+  fprintf (stderr, "\nSERVER ERROR: " _fn " failed (errno = %d)!\n", -_rv);\
+  exit (1);								\
+}
+
+#define vterr(_fn, _rv)							\
+{									\
+  errno = -_rv;								\
+  fprintf (stderr, "\nSERVER ERROR: " _fn " failed (errno = %d)!\n", -_rv);\
+}
+
+#define vtwrn(_fmt, _args...)						\
+  fprintf (stderr, "\nSERVER ERROR: " _fmt "\n", ##_args)		\
+
+#define vtinf(_fmt, _args...)						\
+  fprintf (stdout, "\nvts<w%u>: " _fmt "\n", __wrk_index, ##_args)	\
 
 static inline void
-conn_pool_expand (size_t expand_size)
+conn_pool_expand (vcl_test_server_worker_t * wrk, size_t expand_size)
 {
-  sock_server_main_t *ssm = &sock_server_main;
-  sock_server_conn_t *conn_pool;
-  size_t new_size = ssm->conn_pool_size + expand_size;
+  vcl_test_server_conn_t *conn_pool;
+  size_t new_size = wrk->conn_pool_size + expand_size;
   int i;
 
-  conn_pool = realloc (ssm->conn_pool, new_size * sizeof (*ssm->conn_pool));
+  conn_pool = realloc (wrk->conn_pool, new_size * sizeof (*wrk->conn_pool));
   if (conn_pool)
     {
-      for (i = ssm->conn_pool_size; i < new_size; i++)
+      for (i = wrk->conn_pool_size; i < new_size; i++)
 	{
-	  sock_server_conn_t *conn = &conn_pool[i];
+	  vcl_test_server_conn_t *conn = &conn_pool[i];
 	  memset (conn, 0, sizeof (*conn));
 	  sock_test_cfg_init (&conn->cfg);
 	  sock_test_buf_alloc (&conn->cfg, 1 /* is_rxbuf */ ,
@@ -87,31 +118,27 @@
 	  conn->cfg.txbuf_size = conn->cfg.rxbuf_size;
 	}
 
-      ssm->conn_pool = conn_pool;
-      ssm->conn_pool_size = new_size;
+      wrk->conn_pool = conn_pool;
+      wrk->conn_pool_size = new_size;
     }
   else
     {
-      int errno_val = errno;
-      perror ("ERROR in conn_pool_expand()");
-      fprintf (stderr, "SERVER: ERROR: Memory allocation "
-	       "failed (errno = %d)!\n", errno_val);
+      vterr ("conn_pool_expand()", -errno);
     }
 }
 
-static inline sock_server_conn_t *
-conn_pool_alloc (void)
+static inline vcl_test_server_conn_t *
+conn_pool_alloc (vcl_test_server_worker_t * wrk)
 {
-  sock_server_main_t *ssm = &sock_server_main;
   int i;
 
-  for (i = 0; i < ssm->conn_pool_size; i++)
+  for (i = 0; i < wrk->conn_pool_size; i++)
     {
-      if (!ssm->conn_pool[i].is_alloc)
+      if (!wrk->conn_pool[i].is_alloc)
 	{
-	  ssm->conn_pool[i].endpt.ip = ssm->conn_pool[i].ip;
-	  ssm->conn_pool[i].is_alloc = 1;
-	  return (&ssm->conn_pool[i]);
+	  wrk->conn_pool[i].endpt.ip = wrk->conn_pool[i].ip;
+	  wrk->conn_pool[i].is_alloc = 1;
+	  return (&wrk->conn_pool[i]);
 	}
     }
 
@@ -119,14 +146,15 @@
 }
 
 static inline void
-conn_pool_free (sock_server_conn_t * conn)
+conn_pool_free (vcl_test_server_conn_t * conn)
 {
   conn->fd = 0;
   conn->is_alloc = 0;
 }
 
 static inline void
-sync_config_and_reply (sock_server_conn_t * conn, sock_test_cfg_t * rx_cfg)
+sync_config_and_reply (vcl_test_server_conn_t * conn,
+		       sock_test_cfg_t * rx_cfg)
 {
   conn->cfg = *rx_cfg;
   sock_test_buf_alloc (&conn->cfg, 1 /* is_rxbuf */ ,
@@ -135,7 +163,7 @@
 
   if (conn->cfg.verbose)
     {
-      printf ("\nSERVER (fd %d): Replying to cfg message!\n", conn->fd);
+      vtinf ("(fd %d): Replying to cfg message!\n", conn->fd);
       sock_test_cfg_dump (&conn->cfg, 0 /* is_client */ );
     }
   (void) vcl_test_write (conn->fd, (uint8_t *) & conn->cfg,
@@ -143,10 +171,10 @@
 }
 
 static void
-stream_test_server_start_stop (sock_server_conn_t * conn,
+stream_test_server_start_stop (vcl_test_server_worker_t * wrk,
+			       vcl_test_server_conn_t * conn,
 			       sock_test_cfg_t * rx_cfg)
 {
-  sock_server_main_t *ssm = &sock_server_main;
   int client_fd = conn->fd;
   sock_test_t test = rx_cfg->test;
 
@@ -155,9 +183,9 @@
       int i;
       clock_gettime (CLOCK_REALTIME, &conn->stats.stop);
 
-      for (i = 0; i < ssm->conn_pool_size; i++)
+      for (i = 0; i < wrk->conn_pool_size; i++)
 	{
-	  sock_server_conn_t *tc = &ssm->conn_pool[i];
+	  vcl_test_server_conn_t *tc = &wrk->conn_pool[i];
 
 	  if (tc->cfg.ctrl_handle == conn->fd)
 	    {
@@ -215,7 +243,7 @@
 
 
 static inline void
-stream_test_server (sock_server_conn_t * conn, int rx_bytes)
+stream_test_server (vcl_test_server_conn_t * conn, int rx_bytes)
 {
   int client_fd = conn->fd;
   sock_test_t test = conn->cfg.test;
@@ -230,36 +258,49 @@
     }
 }
 
-static inline void
-new_client (void)
+static void
+vcl_test_server_echo (vcl_test_server_conn_t * conn, int rx_bytes)
 {
-  sock_server_main_t *ssm = &sock_server_main;
+  int tx_bytes, nbytes, pos;
+
+  /* If it looks vaguely like a string,
+   * make sure it's terminated
+   */
+  pos = rx_bytes < conn->buf_size ? rx_bytes : conn->buf_size - 1;
+  ((char *) conn->buf)[pos] = 0;
+  vtinf ("(fd %d): RX (%d bytes) - '%s'", conn->fd, rx_bytes, conn->buf);
+
+  if (conn->cfg.verbose)
+    vtinf ("(fd %d): Echoing back", conn->fd);
+
+  nbytes = strlen ((const char *) conn->buf) + 1;
+  tx_bytes = vcl_test_write (conn->fd, conn->buf, nbytes, &conn->stats,
+			     conn->cfg.verbose);
+  if (tx_bytes >= 0)
+    vtinf ("(fd %d): TX (%d bytes) - '%s'", conn->fd, tx_bytes, conn->buf);
+}
+
+static inline void
+vcl_test_server_new_client (vcl_test_server_worker_t * wrk)
+{
   int client_fd;
-  sock_server_conn_t *conn;
+  vcl_test_server_conn_t *conn;
 
-  if (ssm->conn_pool_size < (ssm->num_conn + SOCK_SERVER_MAX_TEST_CONN + 1))
-    conn_pool_expand (SOCK_SERVER_MAX_TEST_CONN + 1);
-
-  conn = conn_pool_alloc ();
+  conn = conn_pool_alloc (wrk);
   if (!conn)
     {
-      fprintf (stderr, "\nSERVER: ERROR: No free connections!\n");
+      vtwrn ("No free connections!");
       return;
     }
 
-  client_fd = vppcom_session_accept (ssm->listen_fd, &conn->endpt, 0);
+  client_fd = vppcom_session_accept (wrk->listen_fd, &conn->endpt, 0);
   if (client_fd < 0)
     {
-      int errno_val;
-      errno_val = errno = -client_fd;
-      perror ("ERROR in new_client()");
-      fprintf (stderr, "SERVER: ERROR: accept failed "
-	       "(errno = %d)!\n", errno_val);
+      vterr ("vppcom_session_accept()", client_fd);
       return;
     }
 
-  printf ("SERVER: Got a connection -- fd = %d (0x%08x)!\n",
-	  client_fd, client_fd);
+  vtinf ("Got a connection -- fd = %d (0x%08x)!", client_fd, client_fd);
 
   conn->fd = client_fd;
 
@@ -268,18 +309,14 @@
     int rv;
 
     ev.events = EPOLLIN;
-    ev.data.u64 = conn - ssm->conn_pool;
-    rv = vppcom_epoll_ctl (ssm->epfd, EPOLL_CTL_ADD, client_fd, &ev);
+    ev.data.u64 = conn - wrk->conn_pool;
+    rv = vppcom_epoll_ctl (wrk->epfd, EPOLL_CTL_ADD, client_fd, &ev);
     if (rv < 0)
       {
-	int errno_val;
-	errno_val = errno = -rv;
-	perror ("ERROR in new_client()");
-	fprintf (stderr, "SERVER: ERROR: epoll_ctl failed (errno = %d)!\n",
-		 errno_val);
+	vterr ("vppcom_epoll_ctl()", rv);
+	return;
       }
-    else
-      ssm->nfds++;
+    wrk->nfds++;
   }
 }
 
@@ -291,30 +328,58 @@
 	   "  OPTIONS\n"
 	   "  -h               Print this message and exit.\n"
 	   "  -6               Use IPv6\n"
+	   "  -w <num>         Number of workers\n"
 	   "  -u               Use UDP transport layer\n");
   exit (1);
 }
 
-int
-main (int argc, char **argv)
+static void
+vcl_test_init_endpoint_addr (vcl_test_server_main_t * ssm)
 {
-  sock_server_main_t *ssm = &sock_server_main;
-  int client_fd, rv, main_rv = 0;
-  int tx_bytes, rx_bytes, nbytes;
-  sock_server_conn_t *conn;
-  sock_test_cfg_t *rx_cfg;
-  uint32_t xtra = 0;
-  uint64_t xtra_bytes = 0;
-  struct sockaddr_storage servaddr;
-  int errno_val;
-  int c, v, i;
-  uint16_t port = SOCK_TEST_SERVER_PORT;
-  vppcom_endpt_t endpt;
+  struct sockaddr_storage *servaddr = &ssm->servaddr;
+  memset (servaddr, 0, sizeof (*servaddr));
 
-  clib_mem_init_thread_safe (0, 64 << 20);
+  if (ssm->cfg.address_ip6)
+    {
+      struct sockaddr_in6 *server_addr = (struct sockaddr_in6 *) servaddr;
+      server_addr->sin6_family = AF_INET6;
+      server_addr->sin6_addr = in6addr_any;
+      server_addr->sin6_port = htons (ssm->cfg.port);
+    }
+  else
+    {
+      struct sockaddr_in *server_addr = (struct sockaddr_in *) servaddr;
+      server_addr->sin_family = AF_INET;
+      server_addr->sin_addr.s_addr = htonl (INADDR_ANY);
+      server_addr->sin_port = htons (ssm->cfg.port);
+    }
+
+  if (ssm->cfg.address_ip6)
+    {
+      struct sockaddr_in6 *server_addr = (struct sockaddr_in6 *) servaddr;
+      ssm->cfg.endpt.is_ip4 = 0;
+      ssm->cfg.endpt.ip = (uint8_t *) & server_addr->sin6_addr;
+      ssm->cfg.endpt.port = (uint16_t) server_addr->sin6_port;
+    }
+  else
+    {
+      struct sockaddr_in *server_addr = (struct sockaddr_in *) servaddr;
+      ssm->cfg.endpt.is_ip4 = 1;
+      ssm->cfg.endpt.ip = (uint8_t *) & server_addr->sin_addr;
+      ssm->cfg.endpt.port = (uint16_t) server_addr->sin_port;
+    }
+}
+
+void
+vcl_test_server_process_opts (vcl_test_server_main_t * ssm, int argc,
+			      char **argv)
+{
+  int v, c;
+
+  ssm->cfg.proto = VPPCOM_PROTO_TCP;
 
   opterr = 0;
-  while ((c = getopt (argc, argv, "6D")) != -1)
+  while ((c = getopt (argc, argv, "6Dw:")) != -1)
     switch (c)
       {
       case '6':
@@ -322,7 +387,15 @@
 	break;
 
       case 'D':
-	ssm->cfg.transport_udp = 1;
+	ssm->cfg.proto = VPPCOM_PROTO_UDP;
+	break;
+
+      case 'w':
+	v = atoi (optarg);
+	if (v > 1)
+	  ssm->cfg.workers = v;
+	else
+	  vtwrn ("Invalid number of workers %d", v);
 	break;
 
       case '?':
@@ -349,303 +422,252 @@
     }
 
   if (sscanf (argv[optind], "%d", &v) == 1)
-    port = (uint16_t) v;
+    ssm->cfg.port = (uint16_t) v;
   else
     {
       fprintf (stderr, "SERVER: ERROR: Invalid port (%s)!\n", argv[optind]);
       print_usage_and_exit ();
     }
 
-  conn_pool_expand (SOCK_SERVER_MAX_TEST_CONN + 1);
+  vcl_test_init_endpoint_addr (ssm);
+}
 
-  rv = vppcom_app_create ("vcl_test_server");
-  if (rv)
+int
+vcl_test_server_handle_cfg (vcl_test_server_worker_t * wrk,
+			    sock_test_cfg_t * rx_cfg,
+			    vcl_test_server_conn_t * conn, int rx_bytes)
+{
+  if (rx_cfg->verbose)
     {
-      errno_val = errno = -rv;
-      perror ("ERROR in main()");
-      fprintf (stderr, "SERVER: ERROR: vppcom_app_create() failed "
-	       "(errno = %d)!\n", errno_val);
-      return -1;
-    }
-  else
-    {
-      ssm->listen_fd = vppcom_session_create (ssm->cfg.transport_udp ?
-					      VPPCOM_PROTO_UDP :
-					      VPPCOM_PROTO_TCP,
-					      0 /* is_nonblocking */ );
-    }
-  if (ssm->listen_fd < 0)
-    {
-      errno_val = errno = -ssm->listen_fd;
-      perror ("ERROR in main()");
-      fprintf (stderr, "SERVER: ERROR: vppcom_session_create() failed "
-	       "(errno = %d)!\n", errno_val);
-      return -1;
+      vtinf ("(fd %d): Received a cfg msg!", conn->fd);
+      sock_test_cfg_dump (rx_cfg, 0 /* is_client */ );
     }
 
-  memset (&servaddr, 0, sizeof (servaddr));
-
-  if (ssm->cfg.address_ip6)
+  if (rx_bytes != sizeof (*rx_cfg))
     {
-      struct sockaddr_in6 *server_addr = (struct sockaddr_in6 *) &servaddr;
-      server_addr->sin6_family = AF_INET6;
-      server_addr->sin6_addr = in6addr_any;
-      server_addr->sin6_port = htons (port);
-    }
-  else
-    {
-      struct sockaddr_in *server_addr = (struct sockaddr_in *) &servaddr;
-      server_addr->sin_family = AF_INET;
-      server_addr->sin_addr.s_addr = htonl (INADDR_ANY);
-      server_addr->sin_port = htons (port);
-    }
-
-  if (ssm->cfg.address_ip6)
-    {
-      struct sockaddr_in6 *server_addr = (struct sockaddr_in6 *) &servaddr;
-      endpt.is_ip4 = 0;
-      endpt.ip = (uint8_t *) & server_addr->sin6_addr;
-      endpt.port = (uint16_t) server_addr->sin6_port;
-    }
-  else
-    {
-      struct sockaddr_in *server_addr = (struct sockaddr_in *) &servaddr;
-      endpt.is_ip4 = 1;
-      endpt.ip = (uint8_t *) & server_addr->sin_addr;
-      endpt.port = (uint16_t) server_addr->sin_port;
-    }
-
-  rv = vppcom_session_bind (ssm->listen_fd, &endpt);
-  if (rv < 0)
-    {
-      errno_val = errno = -rv;
-      perror ("ERROR in main()");
-      fprintf (stderr, "SERVER: ERROR: bind failed (errno = %d)!\n",
-	       errno_val);
-      return -1;
-    }
-
-  if (!ssm->cfg.transport_udp)
-    {
-      rv = vppcom_session_listen (ssm->listen_fd, 10);
-      if (rv < 0)
+      vtinf ("(fd %d): Invalid cfg msg size %d expected %lu!", conn->fd,
+	     rx_bytes, sizeof (*rx_cfg));
+      conn->cfg.rxbuf_size = 0;
+      conn->cfg.num_writes = 0;
+      if (conn->cfg.verbose)
 	{
-	  errno_val = errno = -rv;
-	  perror ("ERROR in main()");
-	  fprintf (stderr, "SERVER: ERROR: listen failed "
-		   "(errno = %d)!\n", errno_val);
-	  return -1;
+	  vtinf ("(fd %d): Replying to cfg msg", conn->fd);
+	  sock_test_cfg_dump (rx_cfg, 0 /* is_client */ );
 	}
-    }
-
-  ssm->epfd = vppcom_epoll_create ();
-  if (ssm->epfd < 0)
-    {
-      errno_val = errno = -ssm->epfd;
-      perror ("ERROR in main()");
-      fprintf (stderr, "SERVER: ERROR: epoll_create failed (errno = %d)!\n",
-	       errno_val);
+      vcl_test_write (conn->fd, (uint8_t *) & conn->cfg,
+		      sizeof (conn->cfg), NULL, conn->cfg.verbose);
       return -1;
     }
 
-  ssm->listen_ev.events = EPOLLIN;
-  ssm->listen_ev.data.u32 = ~0;
-  rv = vppcom_epoll_ctl (ssm->epfd, EPOLL_CTL_ADD, ssm->listen_fd,
-			 &ssm->listen_ev);
+  switch (rx_cfg->test)
+    {
+    case SOCK_TEST_TYPE_NONE:
+    case SOCK_TEST_TYPE_ECHO:
+      sync_config_and_reply (conn, rx_cfg);
+      break;
+
+    case SOCK_TEST_TYPE_BI:
+    case SOCK_TEST_TYPE_UNI:
+      stream_test_server_start_stop (wrk, conn, rx_cfg);
+      break;
+
+    case SOCK_TEST_TYPE_EXIT:
+      vtinf ("Have a great day conn %d!", conn->fd);
+      vppcom_session_close (conn->fd);
+      conn_pool_free (conn);
+      vtinf ("Closed client fd %d", conn->fd);
+      wrk->nfds--;
+      break;
+
+    default:
+      vtwrn ("Unknown test type %d", rx_cfg->test);
+      sock_test_cfg_dump (rx_cfg, 0 /* is_client */ );
+      break;
+    }
+
+  return 0;
+}
+
+static void
+vcl_test_server_worker_init (vcl_test_server_worker_t * wrk)
+{
+  vcl_test_server_main_t *ssm = &sock_server_main;
+  struct epoll_event listen_ev;
+  int rv;
+
+  __wrk_index = wrk->wrk_index;
+
+  vtinf ("Initializing worker ...");
+
+  conn_pool_expand (wrk, SOCK_SERVER_MAX_TEST_CONN + 1);
+  if (wrk->wrk_index)
+    vppcom_worker_register ();
+
+  wrk->listen_fd = vppcom_session_create (ssm->cfg.proto,
+					  0 /* is_nonblocking */ );
+  if (wrk->listen_fd < 0)
+    vtfail ("vppcom_session_create()", wrk->listen_fd);
+
+  rv = vppcom_session_bind (wrk->listen_fd, &ssm->cfg.endpt);
   if (rv < 0)
+    vtfail ("vppcom_session_bind()", rv);
+
+  if (!(ssm->cfg.proto == VPPCOM_PROTO_UDP))
     {
-      errno_val = errno = -rv;
-      perror ("ERROR in main()");
-      fprintf (stderr, "SERVER: ERROR: epoll_ctl failed "
-	       "(errno = %d)!\n", errno_val);
-      return -1;
+      rv = vppcom_session_listen (wrk->listen_fd, 10);
+      if (rv < 0)
+	vtfail ("vppcom_session_listen()", rv);
     }
-  printf ("\nSERVER: Waiting for a client to connect on port %d...\n", port);
+
+  wrk->epfd = vppcom_epoll_create ();
+  if (wrk->epfd < 0)
+    vtfail ("vppcom_epoll_create()", wrk->epfd);
+
+  listen_ev.events = EPOLLIN;
+  listen_ev.data.u32 = ~0;
+  rv = vppcom_epoll_ctl (wrk->epfd, EPOLL_CTL_ADD, wrk->listen_fd,
+			 &listen_ev);
+  if (rv < 0)
+    vtfail ("vppcom_epoll_ctl", rv);
+
+  vtinf ("Waiting for a client to connect on port %d ...", ssm->cfg.port);
+}
+
+static void *
+vcl_test_server_worker_loop (void *arg)
+{
+  vcl_test_server_main_t *ssm = &sock_server_main;
+  vcl_test_server_worker_t *wrk = arg;
+  vcl_test_server_conn_t *conn;
+  int i, rx_bytes, num_ev;
+  sock_test_cfg_t *rx_cfg;
+
+  if (wrk->wrk_index)
+    vcl_test_server_worker_init (wrk);
 
   while (1)
     {
-      int num_ev;
-      num_ev = vppcom_epoll_wait (ssm->epfd, ssm->wait_events,
+      num_ev = vppcom_epoll_wait (wrk->epfd, wrk->wait_events,
 				  SOCK_SERVER_MAX_EPOLL_EVENTS, 60000.0);
       if (num_ev < 0)
 	{
-	  errno = -num_ev;
-	  perror ("epoll_wait()");
-	  fprintf (stderr, "\nSERVER: ERROR: epoll_wait() "
-		   "failed -- aborting!\n");
-	  main_rv = -1;
-	  goto done;
+	  vterr ("vppcom_epoll_wait()", num_ev);
+	  goto fail;
 	}
       else if (num_ev == 0)
 	{
-	  fprintf (stderr, "\nSERVER: epoll_wait() timeout!\n");
+	  vtinf ("vppcom_epoll_wait() timeout!");
 	  continue;
 	}
       for (i = 0; i < num_ev; i++)
 	{
-	  conn = &ssm->conn_pool[ssm->wait_events[i].data.u32];
-	  if (ssm->wait_events[i].events & (EPOLLHUP | EPOLLRDHUP))
+	  conn = &wrk->conn_pool[wrk->wait_events[i].data.u32];
+	  if (wrk->wait_events[i].events & (EPOLLHUP | EPOLLRDHUP))
 	    {
 	      vppcom_session_close (conn->fd);
 	      continue;
 	    }
-	  if (ssm->wait_events[i].data.u32 == ~0)
+	  if (wrk->wait_events[i].data.u32 == ~0)
 	    {
-	      new_client ();
+	      vcl_test_server_new_client (wrk);
 	      continue;
 	    }
-	  client_fd = conn->fd;
 
-	  if (EPOLLIN & ssm->wait_events[i].events)
+	  if (EPOLLIN & wrk->wait_events[i].events)
 	    {
-	      rx_bytes = vcl_test_read (client_fd, conn->buf,
+	      rx_bytes = vcl_test_read (conn->fd, conn->buf,
 					conn->buf_size, &conn->stats);
-	      if (rx_bytes > 0)
-		{
-		  rx_cfg = (sock_test_cfg_t *) conn->buf;
-		  if (rx_cfg->magic == SOCK_TEST_CFG_CTRL_MAGIC)
-		    {
-		      if (rx_cfg->verbose)
-			{
-			  printf ("SERVER (fd %d): Received a cfg message!\n",
-				  client_fd);
-			  sock_test_cfg_dump (rx_cfg, 0 /* is_client */ );
-			}
 
-		      if (rx_bytes != sizeof (*rx_cfg))
-			{
-			  printf ("SERVER (fd %d): Invalid cfg message "
-				  "size (%d)!\n  Should be %lu bytes.\n",
-				  client_fd, rx_bytes, sizeof (*rx_cfg));
-			  conn->cfg.rxbuf_size = 0;
-			  conn->cfg.num_writes = 0;
-			  if (conn->cfg.verbose)
-			    {
-			      printf ("SERVER (fd %d): Replying to "
-				      "cfg message!\n", client_fd);
-			      sock_test_cfg_dump (rx_cfg, 0 /* is_client */ );
-			    }
-			  vcl_test_write (client_fd, (uint8_t *) & conn->cfg,
-					  sizeof (conn->cfg), NULL,
-					  conn->cfg.verbose);
-			  continue;
-			}
-
-		      switch (rx_cfg->test)
-			{
-			case SOCK_TEST_TYPE_NONE:
-			case SOCK_TEST_TYPE_ECHO:
-			  sync_config_and_reply (conn, rx_cfg);
-			  break;
-
-			case SOCK_TEST_TYPE_BI:
-			case SOCK_TEST_TYPE_UNI:
-			  stream_test_server_start_stop (conn, rx_cfg);
-			  break;
-
-			case SOCK_TEST_TYPE_EXIT:
-			  printf ("SERVER: Have a great day, "
-				  "connection %d!\n", client_fd);
-			  vppcom_session_close (client_fd);
-			  conn_pool_free (conn);
-			  printf ("SERVER: Closed client fd %d\n", client_fd);
-			  ssm->nfds--;
-			  if (!ssm->nfds)
-			    {
-			      printf ("SERVER: All client connections "
-				      "closed.\n\nSERVER: "
-				      "May the force be with you!\n\n");
-			      goto done;
-			    }
-			  break;
-
-			default:
-			  fprintf (stderr,
-				   "SERVER: ERROR: Unknown test type!\n");
-			  sock_test_cfg_dump (rx_cfg, 0 /* is_client */ );
-			  break;
-			}
-		      continue;
-		    }
-
-		  else if ((conn->cfg.test == SOCK_TEST_TYPE_UNI) ||
-			   (conn->cfg.test == SOCK_TEST_TYPE_BI))
-		    {
-		      stream_test_server (conn, rx_bytes);
-		      continue;
-		    }
-
-		  else if (isascii (conn->buf[0]))
-		    {
-		      /* If it looks vaguely like a string,
-		       * make sure it's terminated.
-		       */
-		      ((char *) conn->buf)[rx_bytes <
-					   conn->buf_size ? rx_bytes :
-					   conn->buf_size - 1] = 0;
-		      printf ("SERVER (fd %d): RX (%d bytes) - '%s'\n",
-			      conn->fd, rx_bytes, conn->buf);
-		    }
-		}
-	      else		// rx_bytes < 0
+	      if (rx_bytes <= 0)
 		{
 		  if (errno == ECONNRESET)
 		    {
-		      printf ("\nSERVER: Connection reset by remote peer.\n"
-			      "  Y'all have a great day now!\n\n");
-		      break;
+		      vtinf ("Connection reset by remote peer.\n");
+		      goto fail;
 		    }
 		  else
 		    continue;
 		}
 
-	      if (isascii (conn->buf[0]))
+	      rx_cfg = (sock_test_cfg_t *) conn->buf;
+	      if (rx_cfg->magic == SOCK_TEST_CFG_CTRL_MAGIC)
 		{
-		  /* If it looks vaguely like a string,
-		   * make sure it's terminated
-		   */
-		  ((char *) conn->buf)[rx_bytes <
-				       conn->buf_size ? rx_bytes :
-				       conn->buf_size - 1] = 0;
-		  if (xtra)
-		    fprintf (stderr, "SERVER: ERROR: "
-			     "FIFO not drained in previous test!\n"
-			     "       extra chunks %u (0x%x)\n"
-			     "        extra bytes %lu (0x%lx)\n",
-			     xtra, xtra, xtra_bytes, xtra_bytes);
-
-		  xtra = 0;
-		  xtra_bytes = 0;
-
-		  if (conn->cfg.verbose)
-		    printf ("SERVER (fd %d): Echoing back\n", client_fd);
-
-		  nbytes = strlen ((const char *) conn->buf) + 1;
-
-		  tx_bytes = vcl_test_write (client_fd, conn->buf,
-					     nbytes, &conn->stats,
-					     conn->cfg.verbose);
-		  if (tx_bytes >= 0)
-		    printf ("SERVER (fd %d): TX (%d bytes) - '%s'\n",
-			    conn->fd, tx_bytes, conn->buf);
+		  vcl_test_server_handle_cfg (wrk, rx_cfg, conn, rx_bytes);
+		  if (!wrk->nfds)
+		    {
+		      vtinf ("All client connections closed\n");
+		      vtinf ("May the force be with you!\n");
+		      goto done;
+		    }
+		  continue;
 		}
-	      else		// Extraneous read data from non-echo tests???
+	      else if ((conn->cfg.test == SOCK_TEST_TYPE_UNI)
+		       || (conn->cfg.test == SOCK_TEST_TYPE_BI))
 		{
-		  xtra++;
-		  xtra_bytes += rx_bytes;
+		  stream_test_server (conn, rx_bytes);
+		  continue;
 		}
+	      else if (isascii (conn->buf[0]))
+		{
+		  vcl_test_server_echo (conn, rx_bytes);
+		}
+	      else
+		{
+		  vtwrn ("FIFO not drained! extra bytes %d", rx_bytes);
+		}
+	    }
+	  else
+	    {
+	      vtwrn ("Unhandled event");
+	      goto fail;
 	    }
 	}
     }
 
+fail:
+  ssm->worker_fails -= 1;
+
 done:
-  vppcom_session_close (ssm->listen_fd);
+  vppcom_session_close (wrk->listen_fd);
+  if (wrk->conn_pool)
+    free (wrk->conn_pool);
+  ssm->active_workers -= 1;
+  return 0;
+}
+
+int
+main (int argc, char **argv)
+{
+  vcl_test_server_main_t *ssm = &sock_server_main;
+  int rv, i;
+
+  clib_mem_init_thread_safe (0, 64 << 20);
+  ssm->cfg.port = SOCK_TEST_SERVER_PORT;
+  ssm->cfg.workers = 1;
+  vcl_test_server_process_opts (ssm, argc, argv);
+
+  rv = vppcom_app_create ("vcl_test_server");
+  if (rv)
+    vtfail ("vppcom_app_create()", rv);
+
+  ssm->workers = calloc (ssm->cfg.workers, sizeof (*ssm->workers));
+  vcl_test_server_worker_init (&ssm->workers[0]);
+  for (i = 1; i < ssm->cfg.workers; i++)
+    {
+      ssm->workers[i].wrk_index = i;
+      rv = pthread_create (&ssm->workers[i].thread_handle, NULL,
+			   vcl_test_server_worker_loop,
+			   (void *) &ssm->workers[i]);
+    }
+  vcl_test_server_worker_loop (&ssm->workers[0]);
+
+  while (ssm->active_workers)
+    ;
+
   vppcom_app_destroy ();
+  free (ssm->workers);
 
-  if (ssm->conn_pool)
-    free (ssm->conn_pool);
-
-  return main_rv;
+  return ssm->worker_fails;
 }
 
 /*
