Index: src/xplcommon/posix/LocalServerSocket.cc
===================================================================
--- src/xplcommon/posix/LocalServerSocket.cc	(revision 14)
+++ src/xplcommon/posix/LocalServerSocket.cc	(revision 18)
@@ -36,4 +36,5 @@
 #include <pwd.h>
 #include <unistd.h>
+#include <poll.h>
 
 #include <sys/socket.h>
@@ -87,4 +88,20 @@
 //------------------------------------------------------------------------------
 
+bool LocalServerSocket::isReady()
+{
+    return false;
+}
+
+//------------------------------------------------------------------------------
+
+void LocalServerSocket::handleEvents(short events)
+{
+    if ((events&POLLIN)==POLLIN) {
+        acceptor.accept();
+    }
+}
+
+//------------------------------------------------------------------------------
+
 // Local Variables:
 // mode: C++
Index: src/xplcommon/posix/LocalServerSocket.h
===================================================================
--- src/xplcommon/posix/LocalServerSocket.h	(revision 15)
+++ src/xplcommon/posix/LocalServerSocket.h	(revision 18)
@@ -94,4 +94,16 @@
     LocalAcceptor& getAcceptor();
 
+protected:
+    /**
+     * Indicate if the waitable is ready, i.e. there is no need to
+     * wait for it.
+     */
+    virtual bool isReady();
+
+    /**
+     * Handle the given events.
+     */
+    virtual void handleEvents(short events);
+
     friend class LocalAcceptor;
 };
Index: test/Makefile.am
===================================================================
--- test/Makefile.am	(revision 4)
+++ test/Makefile.am	(revision 18)
@@ -1,6 +1,9 @@
 INCLUDES=-I$(top_srcdir)/src
 
-noinst_PROGRAMS=testevent
+noinst_PROGRAMS=testevent testlocsock
 
 testevent_SOURCES=testevent.cc
 testevent_LDADD=../src/xplcommon/libxplcommon.la -lpthread
+
+testlocsock_SOURCES=testlocsock.cc
+testlocsock_LDADD=../src/xplcommon/libxplcommon.la -lpthread
Index: test/testlocsock.cc
===================================================================
--- test/testlocsock.cc	(revision 18)
+++ test/testlocsock.cc	(revision 18)
@@ -0,0 +1,151 @@
+// Copyright (c) 2012 by István Váradi
+
+// This file is part of libxplcommon, a common utility library for
+// development related to X-Plane
+
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+
+// 1. Redistributions of source code must retain the above copyright notice, this
+//    list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright notice,
+//    this list of conditions and the following disclaimer in the documentation
+//    and/or other materials provided with the distribution.
+
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+// The views and conclusions contained in the software and documentation are those
+// of the authors and should not be interpreted as representing official policies,
+// either expressed or implied, of the FreeBSD Project.
+
+//------------------------------------------------------------------------------
+
+#include <xplcommon/Thread.h>
+#include <xplcommon/Waiter.h>
+#include <xplcommon/LocalServerSocket.h>
+#include <xplcommon/LocalAcceptor.h>
+#include <xplcommon/LocalSocket.h>
+#include <xplcommon/LocalClientSocket.h>
+#include <xplcommon/Connector.h>
+#include <xplcommon/ReadingBuffer.h>
+#include <xplcommon/WritingBuffer.h>
+
+#include <cstdio>
+
+//------------------------------------------------------------------------------
+
+using xplcommon::Thread;
+using xplcommon::Waiter;
+using xplcommon::LocalServerSocket;
+using xplcommon::LocalAcceptor;
+using xplcommon::LocalSocket;
+using xplcommon::LocalClientSocket;
+using xplcommon::Connector;
+
+//------------------------------------------------------------------------------
+
+class ServerThread : public Thread
+{
+    virtual void run();
+};
+
+//------------------------------------------------------------------------------
+
+void ServerThread::run()
+{
+    printf("ServerThread::run\n");
+
+    Waiter waiter;
+
+    LocalServerSocket serverSocket("test", &waiter);
+    LocalAcceptor& acceptor = serverSocket.getAcceptor();
+
+    while(true) {
+        while(!acceptor.accept()) {
+            if (acceptor.failed()) {
+                printf("ServerThread::run: acceptor failed...\n");
+                return;
+            }
+            printf("ServerThread::run: waiting...\n");
+            waiter.wait();
+        }
+
+        printf("ServerThread::run: waiting done, received connection\n");
+        LocalSocket* socket = acceptor.getSocket();
+        delete socket;
+        break;
+    }
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+class ClientThread : public Thread
+{
+public:
+    virtual void run();
+};
+
+//------------------------------------------------------------------------------
+
+void ClientThread::run()
+{
+    printf("ClientThread::run: sleeping\n");
+    sleep(2000);
+    printf("ClientThread::run: connecting\n");
+
+    Waiter waiter;
+
+    LocalClientSocket socket("test", &waiter);
+
+    Connector& connector = socket.getConnector();
+
+    while(!connector.connect()) {
+        if (connector.failed()) {
+            printf("ClientThread::run: connector failed...\n");
+            return;
+        }
+        printf("ClientThread::run: waiting...\n");
+        waiter.wait();
+    }
+
+    printf("ClientThread::run: connected\n");
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+int main()
+{
+    ServerThread serverThread;
+    ClientThread clientThread;
+
+    printf("Starting threads\n");
+    serverThread.start();
+    clientThread.start();
+
+    printf("Waiting for the client thread\n");
+    clientThread.join();
+    printf("Waiting for the server thread\n");
+    serverThread.join();
+    printf("Both threads returned\n");
+
+    return 0;
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
