Index: src/hu/varadiistvan/scpl/io/_posix/.copyright
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/.copyright	(revision 6)
+++ src/hu/varadiistvan/scpl/io/_posix/.copyright	(revision 6)
@@ -0,0 +1,23 @@
+// 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.
Index: src/hu/varadiistvan/scpl/io/_posix/.copyright
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/.copyright	(revision 6)
+++ 	(revision )
@@ -1,23 +1,0 @@
-// 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.
Index: src/hu/varadiistvan/scpl/io/_posix/.guardns
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/.guardns	(revision 6)
+++ src/hu/varadiistvan/scpl/io/_posix/.guardns	(revision 6)
@@ -0,0 +1,1 @@
+posix
Index: src/hu/varadiistvan/scpl/io/_posix/.guardns
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/.guardns	(revision 6)
+++ 	(revision )
@@ -1,1 +1,0 @@
-posix
Index: src/hu/varadiistvan/scpl/io/_posix/.namespace
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/.namespace	(revision 6)
+++ src/hu/varadiistvan/scpl/io/_posix/.namespace	(revision 6)
@@ -0,0 +1,4 @@
+hu
+varadiistvan
+scpl
+io
Index: src/hu/varadiistvan/scpl/io/_posix/.namespace
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/.namespace	(revision 6)
+++ 	(revision )
@@ -1,4 +1,0 @@
-hu
-varadiistvan
-scpl
-io
Index: src/hu/varadiistvan/scpl/io/_posix/.srcmessage
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/.srcmessage	(revision 6)
+++ src/hu/varadiistvan/scpl/io/_posix/.srcmessage	(revision 6)
@@ -0,0 +1,1 @@
+// This file is part of VSCPL, a simple cross-platform utility library
Index: src/hu/varadiistvan/scpl/io/_posix/.srcmessage
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/.srcmessage	(revision 6)
+++ 	(revision )
@@ -1,1 +1,0 @@
-// This file is part of VSCPL, a simple cross-platform utility library
Index: src/hu/varadiistvan/scpl/io/_posix/Acceptor.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Acceptor.cc	(revision 8)
+++ src/hu/varadiistvan/scpl/io/_posix/Acceptor.cc	(revision 8)
@@ -0,0 +1,79 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "Acceptor.h"
+
+#include "ServerSocket.h"
+
+#include <poll.h>
+#include <sys/socket.h>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::Acceptor;
+
+//------------------------------------------------------------------------------
+
+Acceptor::~Acceptor()
+{
+    delete [] address;
+}
+
+//------------------------------------------------------------------------------
+
+bool Acceptor::accept()
+{
+    if (failed()) return false;
+    if (acceptedFD>=0) return true;
+
+    size_t addrlen = addressLength;
+    int result = socket.accept(reinterpret_cast<struct ::sockaddr*>(address),
+                               (address==0) ? 0 : &addrlen);
+    if (result<0) {
+        if (socket.failed()) {
+            socket.events &= ~POLLIN;
+        } else {
+            socket.events |= POLLIN;
+        }
+        return false;
+    } else {
+        acceptedFD = result;
+        socket.events &= ~POLLIN;
+        return true;
+    }
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Acceptor.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Acceptor.cc	(revision 8)
+++ 	(revision )
@@ -1,79 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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 "Acceptor.h"
-
-#include "ServerSocket.h"
-
-#include <poll.h>
-#include <sys/socket.h>
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::io::Acceptor;
-
-//------------------------------------------------------------------------------
-
-Acceptor::~Acceptor()
-{
-    delete [] address;
-}
-
-//------------------------------------------------------------------------------
-
-bool Acceptor::accept()
-{
-    if (failed()) return false;
-    if (acceptedFD>=0) return true;
-
-    size_t addrlen = addressLength;
-    int result = socket.accept(reinterpret_cast<struct ::sockaddr*>(address),
-                               (address==0) ? 0 : &addrlen);
-    if (result<0) {
-        if (socket.failed()) {
-            socket.events &= ~POLLIN;
-        } else {
-            socket.events |= POLLIN;
-        }
-        return false;
-    } else {
-        acceptedFD = result;
-        socket.events &= ~POLLIN;
-        return true;
-    }
-}
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Acceptor.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Acceptor.h	(revision 31)
+++ src/hu/varadiistvan/scpl/io/_posix/Acceptor.h	(revision 31)
@@ -0,0 +1,166 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_ACCEPTOR_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_ACCEPTOR_H
+//------------------------------------------------------------------------------
+
+#include "../Failable.h"
+#include "../BufferedStreamAcceptor.h"
+
+#include "ServerSocket.h"
+
+#include <cstdlib>
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * Class representing the accepting of an incoming connection on a
+ * socket.
+ */
+class Acceptor : public FailableReference<Acceptor>,
+                 public BufferedStreamAcceptor
+{
+protected:
+    /**
+     * The socket we belong to.
+     */
+    ServerSocket& socket;
+
+    /**
+     * The file descriptor accepted the last time.
+     */
+    int acceptedFD;
+
+    /**
+     * The buffer for the remote address, if we are interested.
+     */
+    unsigned char* address;
+
+    /**
+     * The length of the remote address buffer.
+     */
+    size_t addressLength;
+
+protected:
+    /**
+     * Construct the acceptor.
+     *
+     * @param addressLength the length of the buffer for the peer
+     * address. If 0, not buffer will be created.
+     */
+    Acceptor(ServerSocket* socket, size_t addressLength = 0);
+
+public:
+    /**
+     * Destroy the acceptor.
+     */
+    virtual ~Acceptor();
+
+    /**
+     * Start accepting a connection.
+     *
+     * If a connection is already accepted, but not retrieved yet, it
+     * returns true.
+     *
+     * If a new socket becomes immediately available, it returns true.
+     *
+     * If some error occurs, the acceptor is marked as failed.
+     */
+    bool accept();
+
+protected:
+    /**
+     * Called when a connection gets processed and we can become ready
+     * for the next one.
+     */
+    void connectionProcessed();
+
+private:
+    /**
+     * Get the failable object.
+     */
+    const Failable& getFailable() const;
+
+    /**
+     * Get the failable object.
+     */
+    Failable& getFailable();
+
+    friend class FailableReference<Acceptor>;
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline Acceptor::Acceptor(ServerSocket* socket, size_t addressLength) :
+    socket(*socket),
+    acceptedFD(-1),
+    address( (addressLength==0) ? 0 : new unsigned char[addressLength]),
+    addressLength(addressLength)
+{
+}
+
+//------------------------------------------------------------------------------
+
+inline void Acceptor::connectionProcessed()
+{
+    acceptedFD = -1;
+}
+
+//------------------------------------------------------------------------------
+
+inline const Failable& Acceptor::getFailable() const
+{
+    return socket;
+}
+
+//------------------------------------------------------------------------------
+
+inline Failable& Acceptor::getFailable()
+{
+    return socket;
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_ACCEPTOR_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Acceptor.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Acceptor.h	(revision 31)
+++ 	(revision )
@@ -1,166 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_ACCEPTOR_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_ACCEPTOR_H
-//------------------------------------------------------------------------------
-
-#include "../Failable.h"
-#include "../BufferedStreamAcceptor.h"
-
-#include "ServerSocket.h"
-
-#include <cstdlib>
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-/**
- * Class representing the accepting of an incoming connection on a
- * socket.
- */
-class Acceptor : public FailableReference<Acceptor>,
-                 public BufferedStreamAcceptor
-{
-protected:
-    /**
-     * The socket we belong to.
-     */
-    ServerSocket& socket;
-
-    /**
-     * The file descriptor accepted the last time.
-     */
-    int acceptedFD;
-
-    /**
-     * The buffer for the remote address, if we are interested.
-     */
-    unsigned char* address;
-
-    /**
-     * The length of the remote address buffer.
-     */
-    size_t addressLength;
-
-protected:
-    /**
-     * Construct the acceptor.
-     *
-     * @param addressLength the length of the buffer for the peer
-     * address. If 0, not buffer will be created.
-     */
-    Acceptor(ServerSocket* socket, size_t addressLength = 0);
-
-public:
-    /**
-     * Destroy the acceptor.
-     */
-    virtual ~Acceptor();
-
-    /**
-     * Start accepting a connection.
-     *
-     * If a connection is already accepted, but not retrieved yet, it
-     * returns true.
-     *
-     * If a new socket becomes immediately available, it returns true.
-     *
-     * If some error occurs, the acceptor is marked as failed.
-     */
-    bool accept();
-
-protected:
-    /**
-     * Called when a connection gets processed and we can become ready
-     * for the next one.
-     */
-    void connectionProcessed();
-
-private:
-    /**
-     * Get the failable object.
-     */
-    const Failable& getFailable() const;
-
-    /**
-     * Get the failable object.
-     */
-    Failable& getFailable();
-
-    friend class FailableReference<Acceptor>;
-};
-
-//------------------------------------------------------------------------------
-// Inline definitions
-//------------------------------------------------------------------------------
-
-inline Acceptor::Acceptor(ServerSocket* socket, size_t addressLength) :
-    socket(*socket),
-    acceptedFD(-1),
-    address( (addressLength==0) ? 0 : new unsigned char[addressLength]),
-    addressLength(addressLength)
-{
-}
-
-//------------------------------------------------------------------------------
-
-inline void Acceptor::connectionProcessed()
-{
-    acceptedFD = -1;
-}
-
-//------------------------------------------------------------------------------
-
-inline const Failable& Acceptor::getFailable() const
-{
-    return socket;
-}
-
-//------------------------------------------------------------------------------
-
-inline Failable& Acceptor::getFailable()
-{
-    return socket;
-}
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_ACCEPTOR_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/BufferedStream.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/BufferedStream.cc	(revision 6)
+++ src/hu/varadiistvan/scpl/io/_posix/BufferedStream.cc	(revision 6)
@@ -0,0 +1,112 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "BufferedStream.h"
+
+#include "ReadingBuffer.h"
+#include "WritingBuffer.h"
+
+#include <unistd.h>
+#include <poll.h>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::BufferedStream;
+
+//------------------------------------------------------------------------------
+
+BufferedStream::BufferedStream(Waiter* waiter, int fd,
+                                   size_t readingCapacity,
+                                   size_t writingCapacity,
+                                   short events) :
+    Waitable(waiter, fd, events),
+    readingBuffer( (readingCapacity==0) ? 0 :
+                   new ReadingBuffer(readingCapacity, this)),
+    writingBuffer( (writingCapacity==0) ? 0 :
+                   new WritingBuffer(writingCapacity, this))
+{
+}
+
+//------------------------------------------------------------------------------
+
+BufferedStream::~BufferedStream()
+{
+    delete writingBuffer;
+    delete readingBuffer;
+}
+
+//------------------------------------------------------------------------------
+
+ssize_t BufferedStream::read(void* dest, size_t length)
+{
+    ssize_t result = ::read(fd, dest, length);
+    if (result<0 && errno!=EAGAIN && errno!=EWOULDBLOCK) {
+        setErrorCodeFromErrno();
+    }
+    return result;
+}
+
+//------------------------------------------------------------------------------
+
+ssize_t BufferedStream::write(const void* src, size_t length)
+{
+    ssize_t result = ::write(fd, src, length);
+    if (result<0 && errno!=EAGAIN && errno!=EWOULDBLOCK) {
+        setErrorCodeFromErrno();
+    }
+    return result;
+}
+
+//------------------------------------------------------------------------------
+
+bool BufferedStream::isReady()
+{
+    return false;
+}
+
+//------------------------------------------------------------------------------
+
+void BufferedStream::handleEvents(short ev)
+{
+    if ((ev&POLLIN)==POLLIN && readingBuffer!=0) {
+        readingBuffer->read();
+    }
+    if ((ev&POLLOUT)==POLLOUT && writingBuffer!=0) {
+        writingBuffer->write();
+    }
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/BufferedStream.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/BufferedStream.cc	(revision 6)
+++ 	(revision )
@@ -1,112 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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 "BufferedStream.h"
-
-#include "ReadingBuffer.h"
-#include "WritingBuffer.h"
-
-#include <unistd.h>
-#include <poll.h>
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::io::BufferedStream;
-
-//------------------------------------------------------------------------------
-
-BufferedStream::BufferedStream(Waiter* waiter, int fd,
-                                   size_t readingCapacity,
-                                   size_t writingCapacity,
-                                   short events) :
-    Waitable(waiter, fd, events),
-    readingBuffer( (readingCapacity==0) ? 0 :
-                   new ReadingBuffer(readingCapacity, this)),
-    writingBuffer( (writingCapacity==0) ? 0 :
-                   new WritingBuffer(writingCapacity, this))
-{
-}
-
-//------------------------------------------------------------------------------
-
-BufferedStream::~BufferedStream()
-{
-    delete writingBuffer;
-    delete readingBuffer;
-}
-
-//------------------------------------------------------------------------------
-
-ssize_t BufferedStream::read(void* dest, size_t length)
-{
-    ssize_t result = ::read(fd, dest, length);
-    if (result<0 && errno!=EAGAIN && errno!=EWOULDBLOCK) {
-        setErrorCodeFromErrno();
-    }
-    return result;
-}
-
-//------------------------------------------------------------------------------
-
-ssize_t BufferedStream::write(const void* src, size_t length)
-{
-    ssize_t result = ::write(fd, src, length);
-    if (result<0 && errno!=EAGAIN && errno!=EWOULDBLOCK) {
-        setErrorCodeFromErrno();
-    }
-    return result;
-}
-
-//------------------------------------------------------------------------------
-
-bool BufferedStream::isReady()
-{
-    return false;
-}
-
-//------------------------------------------------------------------------------
-
-void BufferedStream::handleEvents(short ev)
-{
-    if ((ev&POLLIN)==POLLIN && readingBuffer!=0) {
-        readingBuffer->read();
-    }
-    if ((ev&POLLOUT)==POLLOUT && writingBuffer!=0) {
-        writingBuffer->write();
-    }
-}
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/BufferedStream.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/BufferedStream.h	(revision 6)
+++ src/hu/varadiistvan/scpl/io/_posix/BufferedStream.h	(revision 6)
@@ -0,0 +1,169 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_BUFFEREDSTREAM_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_BUFFEREDSTREAM_H
+//------------------------------------------------------------------------------
+
+#include "Waitable.h"
+
+#include <cstdlib>
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+class ReadingBuffer;
+class WritingBuffer;
+
+//------------------------------------------------------------------------------
+
+/**
+ * A waitable that has a read and/or a write buffer associated with
+ * it.
+ */
+class BufferedStream : public Waitable
+{
+public:
+    /**
+     * The default buffer capacity.
+     */
+    static const size_t DEFAULT_CAPACITY = 4096;
+
+private:
+    /**
+     * The reading buffer. It may be 0, if no reading buffer is
+     * associated with this waitable.
+     */
+    ReadingBuffer* readingBuffer;
+
+    /**
+     * The writing buffer. It may be 0, if no writing buffer is
+     * associated with this waitable.
+     */
+    WritingBuffer* writingBuffer;
+
+protected:
+    /**
+     * Construct the buffered waitable with the given capacities of
+     * the reading and writing buffers. If any of the capacities is 0,
+     * the corresponding buffer will not be created.
+     */
+    BufferedStream(Waiter* waiter = 0, int fd = -1,
+                     size_t readingCapacity = DEFAULT_CAPACITY,
+                     size_t writingCapacity = DEFAULT_CAPACITY,
+                     short events = 0);
+
+public:
+    /**
+     * Destroy the buffered waitable.
+     */
+    virtual ~BufferedStream();
+
+    /**
+     * Get the reference of the reading buffer. Note, that it can be a
+     * 0 reference, if the waitable has no reading buffer.
+     */
+    ReadingBuffer& getReadingBuffer();
+
+    /**
+     * Get the reference of the writing buffer. Note, that it can be a
+     * 0 reference, if the waitable has no writing buffer.
+     */
+    WritingBuffer& getWritingBuffer();
+
+protected:
+    /**
+     * Read using the file descriptor at most the given number of
+     * bytes into the given buffer.
+     *
+     * This default implementation uses the read(2) function for
+     * reading.
+     *
+     * @return the number of bytes read (0 in case of end-of-file or
+     * when the connection is closed), -1 on error. In case of error,
+     * the error code will be set up.
+     */
+    virtual ssize_t read(void* dest, size_t length);
+
+    /**
+     * Write using the file descriptor the given number of bytes from
+     * the given buffer.
+     *
+     * This default implementation uses the write(2) function for
+     * writing.
+     *
+     * @return the number of bytes written, or -1 on error. In case of error,
+     * the error code will be set up.
+     */
+    virtual ssize_t write(const void* src, size_t length);
+
+    /**
+     * Check if the waitable is ready.
+     */
+    virtual bool isReady();
+
+    /**
+     * Handle any events on the file descriptor.
+     */
+    virtual void handleEvents(short events);
+
+    friend class ReadingBuffer;
+    friend class WritingBuffer;
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline ReadingBuffer& BufferedStream::getReadingBuffer()
+{
+    return *readingBuffer;
+}
+
+//------------------------------------------------------------------------------
+
+inline WritingBuffer& BufferedStream::getWritingBuffer()
+{
+    return *writingBuffer;
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_BUFFEREDSTREAM_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/BufferedStream.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/BufferedStream.h	(revision 6)
+++ 	(revision )
@@ -1,169 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_BUFFEREDSTREAM_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_BUFFEREDSTREAM_H
-//------------------------------------------------------------------------------
-
-#include "Waitable.h"
-
-#include <cstdlib>
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-class ReadingBuffer;
-class WritingBuffer;
-
-//------------------------------------------------------------------------------
-
-/**
- * A waitable that has a read and/or a write buffer associated with
- * it.
- */
-class BufferedStream : public Waitable
-{
-public:
-    /**
-     * The default buffer capacity.
-     */
-    static const size_t DEFAULT_CAPACITY = 4096;
-
-private:
-    /**
-     * The reading buffer. It may be 0, if no reading buffer is
-     * associated with this waitable.
-     */
-    ReadingBuffer* readingBuffer;
-
-    /**
-     * The writing buffer. It may be 0, if no writing buffer is
-     * associated with this waitable.
-     */
-    WritingBuffer* writingBuffer;
-
-protected:
-    /**
-     * Construct the buffered waitable with the given capacities of
-     * the reading and writing buffers. If any of the capacities is 0,
-     * the corresponding buffer will not be created.
-     */
-    BufferedStream(Waiter* waiter = 0, int fd = -1,
-                     size_t readingCapacity = DEFAULT_CAPACITY,
-                     size_t writingCapacity = DEFAULT_CAPACITY,
-                     short events = 0);
-
-public:
-    /**
-     * Destroy the buffered waitable.
-     */
-    virtual ~BufferedStream();
-
-    /**
-     * Get the reference of the reading buffer. Note, that it can be a
-     * 0 reference, if the waitable has no reading buffer.
-     */
-    ReadingBuffer& getReadingBuffer();
-
-    /**
-     * Get the reference of the writing buffer. Note, that it can be a
-     * 0 reference, if the waitable has no writing buffer.
-     */
-    WritingBuffer& getWritingBuffer();
-
-protected:
-    /**
-     * Read using the file descriptor at most the given number of
-     * bytes into the given buffer.
-     *
-     * This default implementation uses the read(2) function for
-     * reading.
-     *
-     * @return the number of bytes read (0 in case of end-of-file or
-     * when the connection is closed), -1 on error. In case of error,
-     * the error code will be set up.
-     */
-    virtual ssize_t read(void* dest, size_t length);
-
-    /**
-     * Write using the file descriptor the given number of bytes from
-     * the given buffer.
-     *
-     * This default implementation uses the write(2) function for
-     * writing.
-     *
-     * @return the number of bytes written, or -1 on error. In case of error,
-     * the error code will be set up.
-     */
-    virtual ssize_t write(const void* src, size_t length);
-
-    /**
-     * Check if the waitable is ready.
-     */
-    virtual bool isReady();
-
-    /**
-     * Handle any events on the file descriptor.
-     */
-    virtual void handleEvents(short events);
-
-    friend class ReadingBuffer;
-    friend class WritingBuffer;
-};
-
-//------------------------------------------------------------------------------
-// Inline definitions
-//------------------------------------------------------------------------------
-
-inline ReadingBuffer& BufferedStream::getReadingBuffer()
-{
-    return *readingBuffer;
-}
-
-//------------------------------------------------------------------------------
-
-inline WritingBuffer& BufferedStream::getWritingBuffer()
-{
-    return *writingBuffer;
-}
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_BUFFEREDSTREAM_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/ClientSocket.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/ClientSocket.cc	(revision 8)
+++ src/hu/varadiistvan/scpl/io/_posix/ClientSocket.cc	(revision 8)
@@ -0,0 +1,72 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "ClientSocket.h"
+
+#include "Connector.h"
+
+#include <poll.h>
+
+#include <sys/socket.h>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::ClientSocket;
+
+//------------------------------------------------------------------------------
+
+void ClientSocket::handleEvents(short events)
+{
+    if (connector.connecting && (events&POLLOUT)==POLLOUT) {
+        connector.handleWritable();
+        events &= ~POLLOUT;
+    }
+
+    BufferedStream::handleEvents(events);
+}
+
+//------------------------------------------------------------------------------
+
+bool ClientSocket::connect(const struct sockaddr* addr, size_t addrlen)
+{
+    int result = ::connect(fd, addr, addrlen);
+    if (result<0 && errno!=EINPROGRESS) {
+        setErrorCodeFromErrno();
+    }
+    return result>=0;
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/ClientSocket.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/ClientSocket.cc	(revision 8)
+++ 	(revision )
@@ -1,72 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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 "ClientSocket.h"
-
-#include "Connector.h"
-
-#include <poll.h>
-
-#include <sys/socket.h>
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::io::ClientSocket;
-
-//------------------------------------------------------------------------------
-
-void ClientSocket::handleEvents(short events)
-{
-    if (connector.connecting && (events&POLLOUT)==POLLOUT) {
-        connector.handleWritable();
-        events &= ~POLLOUT;
-    }
-
-    BufferedStream::handleEvents(events);
-}
-
-//------------------------------------------------------------------------------
-
-bool ClientSocket::connect(const struct sockaddr* addr, size_t addrlen)
-{
-    int result = ::connect(fd, addr, addrlen);
-    if (result<0 && errno!=EINPROGRESS) {
-        setErrorCodeFromErrno();
-    }
-    return result>=0;
-}
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/ClientSocket.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/ClientSocket.h	(revision 8)
+++ src/hu/varadiistvan/scpl/io/_posix/ClientSocket.h	(revision 8)
@@ -0,0 +1,111 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_CLIENTSOCKET_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_CLIENTSOCKET_H
+//------------------------------------------------------------------------------
+
+#include "Socket.h"
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+class Connector;
+
+//------------------------------------------------------------------------------
+
+/**
+ * A socket that can be connected to another one.
+ */
+class ClientSocket : public Socket
+{
+private:
+    /**
+     * The connector.
+     */
+    Connector& connector;
+
+protected:
+    /**
+     * Construct the socket with the given parameters.
+     */
+    ClientSocket(int domain, int type, Connector& connector,
+                 Waiter* waiter = 0, int protocol = 0,
+                 size_t readingCapacity = DEFAULT_CAPACITY,
+                 size_t writingCapacity = DEFAULT_CAPACITY);
+
+protected:
+    /**
+     * Handle any events on the file descriptor. If a connection is in
+     * progress, and the incoming events have the EPOLLOUT flag set,
+     * the connector is called to handle the event. Then the parent
+     * class' handleEvents function is called.
+     */
+    virtual void handleEvents(short events);
+
+    /**
+     * Connect the socket to the given address.
+     *
+     * @return whether the connection succeeded or not. If it does not
+     * succeeded, it may be either because of the socket being
+     * non-blocking and some time is needed, or because of a failure,
+     * in which case the error code will be set properly.
+     */
+    bool connect(const struct sockaddr* addr, size_t addrlen);
+
+    friend class Connector;
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline ClientSocket::ClientSocket(int domain, int type, Connector& connector,
+                                  Waiter* waiter, int protocol,
+                                  size_t readingCapacity,
+                                  size_t writingCapacity) :
+    Socket(domain, type, waiter, protocol, readingCapacity, writingCapacity),
+    connector(connector)
+{
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_CLIENTSOCKET_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/ClientSocket.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/ClientSocket.h	(revision 8)
+++ 	(revision )
@@ -1,111 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_CLIENTSOCKET_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_CLIENTSOCKET_H
-//------------------------------------------------------------------------------
-
-#include "Socket.h"
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-class Connector;
-
-//------------------------------------------------------------------------------
-
-/**
- * A socket that can be connected to another one.
- */
-class ClientSocket : public Socket
-{
-private:
-    /**
-     * The connector.
-     */
-    Connector& connector;
-
-protected:
-    /**
-     * Construct the socket with the given parameters.
-     */
-    ClientSocket(int domain, int type, Connector& connector,
-                 Waiter* waiter = 0, int protocol = 0,
-                 size_t readingCapacity = DEFAULT_CAPACITY,
-                 size_t writingCapacity = DEFAULT_CAPACITY);
-
-protected:
-    /**
-     * Handle any events on the file descriptor. If a connection is in
-     * progress, and the incoming events have the EPOLLOUT flag set,
-     * the connector is called to handle the event. Then the parent
-     * class' handleEvents function is called.
-     */
-    virtual void handleEvents(short events);
-
-    /**
-     * Connect the socket to the given address.
-     *
-     * @return whether the connection succeeded or not. If it does not
-     * succeeded, it may be either because of the socket being
-     * non-blocking and some time is needed, or because of a failure,
-     * in which case the error code will be set properly.
-     */
-    bool connect(const struct sockaddr* addr, size_t addrlen);
-
-    friend class Connector;
-};
-
-//------------------------------------------------------------------------------
-// Inline definitions
-//------------------------------------------------------------------------------
-
-inline ClientSocket::ClientSocket(int domain, int type, Connector& connector,
-                                  Waiter* waiter, int protocol,
-                                  size_t readingCapacity,
-                                  size_t writingCapacity) :
-    Socket(domain, type, waiter, protocol, readingCapacity, writingCapacity),
-    connector(connector)
-{
-}
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_CLIENTSOCKET_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Connector.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Connector.cc	(revision 8)
+++ src/hu/varadiistvan/scpl/io/_posix/Connector.cc	(revision 8)
@@ -0,0 +1,92 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "Connector.h"
+
+#include "ClientSocket.h"
+
+#include <poll.h>
+#include <sys/socket.h>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::Connector;
+
+//------------------------------------------------------------------------------
+
+bool Connector::connect()
+{
+    if (connected) return true;
+    if (connecting || failed()) return false;
+
+    size_t addrlen = 0;
+    const struct sockaddr* addr = getAddress(addrlen);
+
+    if (socket.connect(addr, addrlen)) {
+        connected = true;
+        return true;
+    } else if (socket.failed()) {
+        return false;
+    } else {
+        connecting = true;
+        socket.events |= POLLOUT;
+        return false;
+    }
+}
+
+//------------------------------------------------------------------------------
+
+void Connector::handleWritable()
+{
+    if (!connecting) return;
+
+    connecting = false;
+    socket.events &= ~POLLOUT;
+
+    int error = 0;
+    socklen_t len = sizeof(error);
+    if (getsockopt(socket.fd, SOL_SOCKET, SO_ERROR, &error, &len)<0) {
+        socket.setErrorCodeFromErrno();
+    } else {
+        if (error==0) {
+            connected = true;
+        } else {
+            socket.setErrorCode(error);
+        }
+    }
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Connector.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Connector.cc	(revision 8)
+++ 	(revision )
@@ -1,92 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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 "Connector.h"
-
-#include "ClientSocket.h"
-
-#include <poll.h>
-#include <sys/socket.h>
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::io::Connector;
-
-//------------------------------------------------------------------------------
-
-bool Connector::connect()
-{
-    if (connected) return true;
-    if (connecting || failed()) return false;
-
-    size_t addrlen = 0;
-    const struct sockaddr* addr = getAddress(addrlen);
-
-    if (socket.connect(addr, addrlen)) {
-        connected = true;
-        return true;
-    } else if (socket.failed()) {
-        return false;
-    } else {
-        connecting = true;
-        socket.events |= POLLOUT;
-        return false;
-    }
-}
-
-//------------------------------------------------------------------------------
-
-void Connector::handleWritable()
-{
-    if (!connecting) return;
-
-    connecting = false;
-    socket.events &= ~POLLOUT;
-
-    int error = 0;
-    socklen_t len = sizeof(error);
-    if (getsockopt(socket.fd, SOL_SOCKET, SO_ERROR, &error, &len)<0) {
-        socket.setErrorCodeFromErrno();
-    } else {
-        if (error==0) {
-            connected = true;
-        } else {
-            socket.setErrorCode(error);
-        }
-    }
-}
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Connector.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Connector.h	(revision 8)
+++ src/hu/varadiistvan/scpl/io/_posix/Connector.h	(revision 8)
@@ -0,0 +1,162 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_CONNECTOR_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_CONNECTOR_H
+//------------------------------------------------------------------------------
+
+#include "../Failable.h"
+
+#include "ClientSocket.h"
+
+#include <cstdlib>
+
+//------------------------------------------------------------------------------
+
+struct sockaddr;
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * Class representing the creation of a connection to some remote
+ * entity, like a socket or a pipe.
+ */
+class Connector : public FailableReference<Connector>
+{
+private:
+    /**
+     * The socket on behalf of which the connection is being
+     * performed.
+     */
+    ClientSocket& socket;
+
+    /**
+     * Indicate that we are in the process of connecting.
+     */
+    bool connecting;
+
+    /**
+     * Indicate that we are connected.
+     */
+    bool connected;
+
+protected:
+    /**
+     * Construct the connector.
+     */
+    Connector(ClientSocket* socket);
+
+public:
+    /**
+     * Connect to an address properly set up.
+     *
+     * If the connection succeeds immediately, it indicates success.
+     *
+     * If the connection does not succeed, because it would block, it
+     * sets up the socket to wait for the connection to succeed, and
+     * returns failure.
+     *
+     * If the connection fails for another reason, the error code is
+     * set, and false is returned.
+     */
+    bool connect();
+
+protected:
+    /**
+     * Get the parameters for connecting.
+     */
+    virtual const struct sockaddr* getAddress(size_t& addrlen) = 0;
+
+    /**
+     * Handle the event that the socket is writable.
+     *
+     * If connection is in progress, this function returns
+     * immediately.
+     *
+     * Otherwise it reads the error code using getsockopt(), and if it
+     * indicates success, the connector is set to connected, otherwise
+     * it is set to failed.
+     */
+    void handleWritable();
+
+private:
+    /**
+     * Get the failable object.
+     */
+    const Failable& getFailable() const;
+
+    /**
+     * Get the failable object.
+     */
+    Failable& getFailable();
+
+    friend class FailableReference<Connector>;
+    friend class ClientSocket;
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline Connector::Connector(ClientSocket* socket) :
+    socket(*socket),
+    connecting(false),
+    connected(false)
+{
+}
+
+//------------------------------------------------------------------------------
+
+inline const Failable& Connector::getFailable() const
+{
+    return socket;
+}
+
+//------------------------------------------------------------------------------
+
+inline Failable& Connector::getFailable()
+{
+    return socket;
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_CONNECTOR_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Connector.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Connector.h	(revision 8)
+++ 	(revision )
@@ -1,162 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_CONNECTOR_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_CONNECTOR_H
-//------------------------------------------------------------------------------
-
-#include "../Failable.h"
-
-#include "ClientSocket.h"
-
-#include <cstdlib>
-
-//------------------------------------------------------------------------------
-
-struct sockaddr;
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-/**
- * Class representing the creation of a connection to some remote
- * entity, like a socket or a pipe.
- */
-class Connector : public FailableReference<Connector>
-{
-private:
-    /**
-     * The socket on behalf of which the connection is being
-     * performed.
-     */
-    ClientSocket& socket;
-
-    /**
-     * Indicate that we are in the process of connecting.
-     */
-    bool connecting;
-
-    /**
-     * Indicate that we are connected.
-     */
-    bool connected;
-
-protected:
-    /**
-     * Construct the connector.
-     */
-    Connector(ClientSocket* socket);
-
-public:
-    /**
-     * Connect to an address properly set up.
-     *
-     * If the connection succeeds immediately, it indicates success.
-     *
-     * If the connection does not succeed, because it would block, it
-     * sets up the socket to wait for the connection to succeed, and
-     * returns failure.
-     *
-     * If the connection fails for another reason, the error code is
-     * set, and false is returned.
-     */
-    bool connect();
-
-protected:
-    /**
-     * Get the parameters for connecting.
-     */
-    virtual const struct sockaddr* getAddress(size_t& addrlen) = 0;
-
-    /**
-     * Handle the event that the socket is writable.
-     *
-     * If connection is in progress, this function returns
-     * immediately.
-     *
-     * Otherwise it reads the error code using getsockopt(), and if it
-     * indicates success, the connector is set to connected, otherwise
-     * it is set to failed.
-     */
-    void handleWritable();
-
-private:
-    /**
-     * Get the failable object.
-     */
-    const Failable& getFailable() const;
-
-    /**
-     * Get the failable object.
-     */
-    Failable& getFailable();
-
-    friend class FailableReference<Connector>;
-    friend class ClientSocket;
-};
-
-//------------------------------------------------------------------------------
-// Inline definitions
-//------------------------------------------------------------------------------
-
-inline Connector::Connector(ClientSocket* socket) :
-    socket(*socket),
-    connecting(false),
-    connected(false)
-{
-}
-
-//------------------------------------------------------------------------------
-
-inline const Failable& Connector::getFailable() const
-{
-    return socket;
-}
-
-//------------------------------------------------------------------------------
-
-inline Failable& Connector::getFailable()
-{
-    return socket;
-}
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_CONNECTOR_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/LocalAcceptor.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/LocalAcceptor.h	(revision 32)
+++ src/hu/varadiistvan/scpl/io/_posix/LocalAcceptor.h	(revision 32)
@@ -0,0 +1,65 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALACCEPTOR_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALACCEPTOR_H
+//------------------------------------------------------------------------------
+
+#include "SocketAcceptor.h"
+
+#include "LocalSocket.h"
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * An acceptor that provides a LocalSocket for each accepted connection
+ */
+class LocalAcceptor : public SocketAcceptor<LocalSocket>
+{
+private:
+    using SocketAcceptor<LocalSocket>::SocketAcceptor;
+
+    friend class LocalServerSocket;
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALACCEPTOR_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/LocalAcceptor.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/LocalAcceptor.h	(revision 32)
+++ 	(revision )
@@ -1,65 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALACCEPTOR_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALACCEPTOR_H
-//------------------------------------------------------------------------------
-
-#include "SocketAcceptor.h"
-
-#include "LocalSocket.h"
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-/**
- * An acceptor that provides a LocalSocket for each accepted connection
- */
-class LocalAcceptor : public SocketAcceptor<LocalSocket>
-{
-private:
-    using SocketAcceptor<LocalSocket>::SocketAcceptor;
-
-    friend class LocalServerSocket;
-};
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALACCEPTOR_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/LocalClientSocket.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/LocalClientSocket.cc	(revision 8)
+++ src/hu/varadiistvan/scpl/io/_posix/LocalClientSocket.cc	(revision 8)
@@ -0,0 +1,58 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "LocalClientSocket.h"
+
+#include "LocalConnector.h"
+
+#include <sys/socket.h>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::LocalClientSocket;
+
+//------------------------------------------------------------------------------
+
+LocalClientSocket::LocalClientSocket(const char* name, Waiter* waiter,
+                                     size_t readingCapacity,
+                                     size_t writingCapacity) :
+    ClientSocket(AF_UNIX, SOCK_STREAM, connector, waiter, 0,
+                 readingCapacity, writingCapacity),
+    connector(this, name)
+{
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/LocalClientSocket.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/LocalClientSocket.cc	(revision 8)
+++ 	(revision )
@@ -1,58 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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 "LocalClientSocket.h"
-
-#include "LocalConnector.h"
-
-#include <sys/socket.h>
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::io::LocalClientSocket;
-
-//------------------------------------------------------------------------------
-
-LocalClientSocket::LocalClientSocket(const char* name, Waiter* waiter,
-                                     size_t readingCapacity,
-                                     size_t writingCapacity) :
-    ClientSocket(AF_UNIX, SOCK_STREAM, connector, waiter, 0,
-                 readingCapacity, writingCapacity),
-    connector(this, name)
-{
-}
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/LocalClientSocket.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/LocalClientSocket.h	(revision 8)
+++ src/hu/varadiistvan/scpl/io/_posix/LocalClientSocket.h	(revision 8)
@@ -0,0 +1,100 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALCLIENTSOCKET_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALCLIENTSOCKET_H
+//------------------------------------------------------------------------------
+
+#include "ClientSocket.h"
+
+#include "LocalConnector.h"
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * Client socket that connects to a server socket locally (i.e. a Unit
+ * socket).
+ *
+ * The server socket's name should be given. The name will be used as
+ * described for LocalServerSocket.
+ */
+class LocalClientSocket : public ClientSocket
+{
+private:
+    /**
+     * The address to use for connecting.
+     */
+    LocalConnector connector;
+
+public:
+    /**
+     * Construct the client socket with the given name.
+     *
+     * @param waiter the waiter to use for waiting a possible event
+     * occuring on the socket. If given, the socket will be
+     * non-blocking. Otherwise, it will be blocking, and the connect()
+     * function of the Connector might block as well as the reading
+     * and writing buffers.
+     */
+    LocalClientSocket(const char* name, Waiter* waiter = 0,
+                      size_t readingCapacity = DEFAULT_CAPACITY,
+                      size_t writingCapacity = DEFAULT_CAPACITY);
+
+    /**
+     * Get the connector for this client.
+     */
+    LocalConnector& getConnector();
+
+    friend class LocalConnector;
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline LocalConnector& LocalClientSocket::getConnector()
+{
+    return connector;
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALCLIENTSOCKET_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/LocalClientSocket.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/LocalClientSocket.h	(revision 8)
+++ 	(revision )
@@ -1,100 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALCLIENTSOCKET_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALCLIENTSOCKET_H
-//------------------------------------------------------------------------------
-
-#include "ClientSocket.h"
-
-#include "LocalConnector.h"
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-/**
- * Client socket that connects to a server socket locally (i.e. a Unit
- * socket).
- *
- * The server socket's name should be given. The name will be used as
- * described for LocalServerSocket.
- */
-class LocalClientSocket : public ClientSocket
-{
-private:
-    /**
-     * The address to use for connecting.
-     */
-    LocalConnector connector;
-
-public:
-    /**
-     * Construct the client socket with the given name.
-     *
-     * @param waiter the waiter to use for waiting a possible event
-     * occuring on the socket. If given, the socket will be
-     * non-blocking. Otherwise, it will be blocking, and the connect()
-     * function of the Connector might block as well as the reading
-     * and writing buffers.
-     */
-    LocalClientSocket(const char* name, Waiter* waiter = 0,
-                      size_t readingCapacity = DEFAULT_CAPACITY,
-                      size_t writingCapacity = DEFAULT_CAPACITY);
-
-    /**
-     * Get the connector for this client.
-     */
-    LocalConnector& getConnector();
-
-    friend class LocalConnector;
-};
-
-//------------------------------------------------------------------------------
-// Inline definitions
-//------------------------------------------------------------------------------
-
-inline LocalConnector& LocalClientSocket::getConnector()
-{
-    return connector;
-}
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALCLIENTSOCKET_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/LocalConnector.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/LocalConnector.cc	(revision 8)
+++ src/hu/varadiistvan/scpl/io/_posix/LocalConnector.cc	(revision 8)
@@ -0,0 +1,51 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "LocalConnector.h"
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::LocalConnector;
+
+//------------------------------------------------------------------------------
+
+const struct sockaddr* LocalConnector::getAddress(size_t& addrlen)
+{
+    addrlen = sizeof(address);
+    return reinterpret_cast<const struct sockaddr*>(&address);
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/LocalConnector.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/LocalConnector.cc	(revision 8)
+++ 	(revision )
@@ -1,51 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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 "LocalConnector.h"
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::io::LocalConnector;
-
-//------------------------------------------------------------------------------
-
-const struct sockaddr* LocalConnector::getAddress(size_t& addrlen)
-{
-    addrlen = sizeof(address);
-    return reinterpret_cast<const struct sockaddr*>(&address);
-}
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/LocalConnector.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/LocalConnector.h	(revision 8)
+++ src/hu/varadiistvan/scpl/io/_posix/LocalConnector.h	(revision 8)
@@ -0,0 +1,89 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALCONNECTOR_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALCONNECTOR_H
+//------------------------------------------------------------------------------
+
+#include "Connector.h"
+
+#include "LocalServerSocket.h"
+
+#include <sys/socket.h>
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * The connector class used by the local client socket.
+ */
+class LocalConnector : public Connector
+{
+private:
+    /**
+     * The reference to the corresponding socket's address.
+     */
+    struct sockaddr_un address;
+
+public:
+    /**
+     * Create the connector for the given local client socket.
+     */
+    LocalConnector(ClientSocket* socket, const char* name);
+
+protected:
+    /**
+     * Get the address.
+     */
+    virtual const struct sockaddr* getAddress(size_t& addrlen);
+};
+
+//------------------------------------------------------------------------------
+
+inline LocalConnector::LocalConnector(ClientSocket* socket, const char* name) :
+    Connector(socket)
+{
+    address.sun_family = AF_UNIX;
+    LocalServerSocket::setupPath(address, name);
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALCONNECTOR_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/LocalConnector.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/LocalConnector.h	(revision 8)
+++ 	(revision )
@@ -1,89 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALCONNECTOR_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALCONNECTOR_H
-//------------------------------------------------------------------------------
-
-#include "Connector.h"
-
-#include "LocalServerSocket.h"
-
-#include <sys/socket.h>
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-/**
- * The connector class used by the local client socket.
- */
-class LocalConnector : public Connector
-{
-private:
-    /**
-     * The reference to the corresponding socket's address.
-     */
-    struct sockaddr_un address;
-
-public:
-    /**
-     * Create the connector for the given local client socket.
-     */
-    LocalConnector(ClientSocket* socket, const char* name);
-
-protected:
-    /**
-     * Get the address.
-     */
-    virtual const struct sockaddr* getAddress(size_t& addrlen);
-};
-
-//------------------------------------------------------------------------------
-
-inline LocalConnector::LocalConnector(ClientSocket* socket, const char* name) :
-    Connector(socket)
-{
-    address.sun_family = AF_UNIX;
-    LocalServerSocket::setupPath(address, name);
-}
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALCONNECTOR_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/LocalServerSocket.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/LocalServerSocket.cc	(revision 8)
+++ src/hu/varadiistvan/scpl/io/_posix/LocalServerSocket.cc	(revision 8)
@@ -0,0 +1,109 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "LocalServerSocket.h"
+
+#include <cstdio>
+
+#include <pwd.h>
+#include <unistd.h>
+#include <poll.h>
+
+#include <sys/socket.h>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::LocalServerSocket;
+
+//------------------------------------------------------------------------------
+
+void LocalServerSocket::setupPath(struct sockaddr_un& addr, const char* name)
+{
+#ifndef P_tmpdir
+#define P_tmpdir "/tmp"
+#endif
+    struct passwd* passwd = getpwuid(geteuid());
+    const char* userName = (passwd==0) ? "unknown" : passwd->pw_name;
+    snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s-%s",
+             P_tmpdir, name, userName);
+}
+
+//------------------------------------------------------------------------------
+
+LocalServerSocket::LocalServerSocket(const char* name, Waiter* waiter) :
+    ServerSocket(AF_UNIX, SOCK_STREAM, waiter),
+    acceptor(this)
+{
+    sun.sun_family = AF_UNIX;
+    setupPath(sun, name);
+
+    unlink(sun.sun_path);
+
+    if (bind(reinterpret_cast<struct sockaddr*>(&sun), sizeof(sun), false)<0) {
+        setErrorCode(errno);
+        return;
+    }
+
+    if (listen()<0) {
+        setErrorCode(errno);
+        return;
+    }
+}
+
+//------------------------------------------------------------------------------
+
+LocalServerSocket::~LocalServerSocket()
+{
+    unlink(sun.sun_path);
+}
+
+//------------------------------------------------------------------------------
+
+bool LocalServerSocket::isReady()
+{
+    return false;
+}
+
+//------------------------------------------------------------------------------
+
+void LocalServerSocket::handleEvents(short events)
+{
+    if ((events&POLLIN)==POLLIN) {
+        acceptor.accept();
+    }
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/LocalServerSocket.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/LocalServerSocket.cc	(revision 8)
+++ 	(revision )
@@ -1,109 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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 "LocalServerSocket.h"
-
-#include <cstdio>
-
-#include <pwd.h>
-#include <unistd.h>
-#include <poll.h>
-
-#include <sys/socket.h>
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::io::LocalServerSocket;
-
-//------------------------------------------------------------------------------
-
-void LocalServerSocket::setupPath(struct sockaddr_un& addr, const char* name)
-{
-#ifndef P_tmpdir
-#define P_tmpdir "/tmp"
-#endif
-    struct passwd* passwd = getpwuid(geteuid());
-    const char* userName = (passwd==0) ? "unknown" : passwd->pw_name;
-    snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s-%s",
-             P_tmpdir, name, userName);
-}
-
-//------------------------------------------------------------------------------
-
-LocalServerSocket::LocalServerSocket(const char* name, Waiter* waiter) :
-    ServerSocket(AF_UNIX, SOCK_STREAM, waiter),
-    acceptor(this)
-{
-    sun.sun_family = AF_UNIX;
-    setupPath(sun, name);
-
-    unlink(sun.sun_path);
-
-    if (bind(reinterpret_cast<struct sockaddr*>(&sun), sizeof(sun), false)<0) {
-        setErrorCode(errno);
-        return;
-    }
-
-    if (listen()<0) {
-        setErrorCode(errno);
-        return;
-    }
-}
-
-//------------------------------------------------------------------------------
-
-LocalServerSocket::~LocalServerSocket()
-{
-    unlink(sun.sun_path);
-}
-
-//------------------------------------------------------------------------------
-
-bool LocalServerSocket::isReady()
-{
-    return false;
-}
-
-//------------------------------------------------------------------------------
-
-void LocalServerSocket::handleEvents(short events)
-{
-    if ((events&POLLIN)==POLLIN) {
-        acceptor.accept();
-    }
-}
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/LocalServerSocket.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/LocalServerSocket.h	(revision 8)
+++ src/hu/varadiistvan/scpl/io/_posix/LocalServerSocket.h	(revision 8)
@@ -0,0 +1,130 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALSERVERSOCKET_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALSERVERSOCKET_H
+//------------------------------------------------------------------------------
+
+#include "ServerSocket.h"
+
+#include "LocalAcceptor.h"
+
+#include <sys/un.h>
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * A server socket that works locally, i.e. a Unix socket.
+ *
+ * It is identified by a name that should be unique for the user. The
+ * actual socket will be created with the name /tmp/<name>-<username>.
+ */
+class LocalServerSocket : public ServerSocket
+{
+public:
+    /**
+     * Fill in the path of the socket with the given name.
+     */
+    static void setupPath(struct sockaddr_un& addr, const char* name);
+
+private:
+    /**
+     * Our address (to be used when deleting the file in the
+     * destructor.
+     */
+    struct sockaddr_un sun;
+
+    /**
+     * The acceptor to use for accepting connections.
+     */
+    LocalAcceptor acceptor;
+
+public:
+    /**
+     * Construct the socket with the given name.
+     *
+     * It will be bound to the name and able to listen for incoming
+     * connections.
+     *
+     * @param waiter the waiter to use for waiting a possible event
+     * occuring on the socket. If given, the socket will be
+     * non-blocking. Otherwise, it will be blocking, and the accept()
+     * function of the Acceptor might block.
+     */
+    LocalServerSocket(const char* name, Waiter* waiter = 0);
+
+    /**
+     * Destroy the socket by deleting the file.
+     */
+    virtual ~LocalServerSocket();
+
+    /**
+     * Get the acceptor.
+     */
+    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;
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline LocalAcceptor& LocalServerSocket::getAcceptor()
+{
+    return acceptor;
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALSERVERSOCKET_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/LocalServerSocket.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/LocalServerSocket.h	(revision 8)
+++ 	(revision )
@@ -1,130 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALSERVERSOCKET_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALSERVERSOCKET_H
-//------------------------------------------------------------------------------
-
-#include "ServerSocket.h"
-
-#include "LocalAcceptor.h"
-
-#include <sys/un.h>
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-/**
- * A server socket that works locally, i.e. a Unix socket.
- *
- * It is identified by a name that should be unique for the user. The
- * actual socket will be created with the name /tmp/<name>-<username>.
- */
-class LocalServerSocket : public ServerSocket
-{
-public:
-    /**
-     * Fill in the path of the socket with the given name.
-     */
-    static void setupPath(struct sockaddr_un& addr, const char* name);
-
-private:
-    /**
-     * Our address (to be used when deleting the file in the
-     * destructor.
-     */
-    struct sockaddr_un sun;
-
-    /**
-     * The acceptor to use for accepting connections.
-     */
-    LocalAcceptor acceptor;
-
-public:
-    /**
-     * Construct the socket with the given name.
-     *
-     * It will be bound to the name and able to listen for incoming
-     * connections.
-     *
-     * @param waiter the waiter to use for waiting a possible event
-     * occuring on the socket. If given, the socket will be
-     * non-blocking. Otherwise, it will be blocking, and the accept()
-     * function of the Acceptor might block.
-     */
-    LocalServerSocket(const char* name, Waiter* waiter = 0);
-
-    /**
-     * Destroy the socket by deleting the file.
-     */
-    virtual ~LocalServerSocket();
-
-    /**
-     * Get the acceptor.
-     */
-    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;
-};
-
-//------------------------------------------------------------------------------
-// Inline definitions
-//------------------------------------------------------------------------------
-
-inline LocalAcceptor& LocalServerSocket::getAcceptor()
-{
-    return acceptor;
-}
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALSERVERSOCKET_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/LocalSocket.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/LocalSocket.h	(revision 32)
+++ src/hu/varadiistvan/scpl/io/_posix/LocalSocket.h	(revision 32)
@@ -0,0 +1,79 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALSOCKET_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALSOCKET_H
+//------------------------------------------------------------------------------
+
+#include "Socket.h"
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * A socket that works on a local (Unix) connection.
+ */
+class LocalSocket : public Socket
+{
+private:
+    /**
+     * Construct the socket with the given parameters.
+     */
+    LocalSocket(int fd, Waiter* waiter = 0,
+                size_t readingCapacity = DEFAULT_CAPACITY,
+                size_t writingCapacity = DEFAULT_CAPACITY);
+
+    friend class SocketAcceptor<LocalSocket>;
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline LocalSocket::LocalSocket(int fd, Waiter* waiter,
+                                size_t readingCapacity,
+                                size_t writingCapacity) :
+    Socket(fd, waiter, readingCapacity, writingCapacity)
+{
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALSOCKET_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/LocalSocket.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/LocalSocket.h	(revision 32)
+++ 	(revision )
@@ -1,79 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALSOCKET_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALSOCKET_H
-//------------------------------------------------------------------------------
-
-#include "Socket.h"
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-/**
- * A socket that works on a local (Unix) connection.
- */
-class LocalSocket : public Socket
-{
-private:
-    /**
-     * Construct the socket with the given parameters.
-     */
-    LocalSocket(int fd, Waiter* waiter = 0,
-                size_t readingCapacity = DEFAULT_CAPACITY,
-                size_t writingCapacity = DEFAULT_CAPACITY);
-
-    friend class SocketAcceptor<LocalSocket>;
-};
-
-//------------------------------------------------------------------------------
-// Inline definitions
-//------------------------------------------------------------------------------
-
-inline LocalSocket::LocalSocket(int fd, Waiter* waiter,
-                                size_t readingCapacity,
-                                size_t writingCapacity) :
-    Socket(fd, waiter, readingCapacity, writingCapacity)
-{
-}
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_LOCALSOCKET_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Makefile.am
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Makefile.am	(revision 33)
+++ src/hu/varadiistvan/scpl/io/_posix/Makefile.am	(revision 33)
@@ -0,0 +1,51 @@
+AM_CPPFLAGS=-I$(top_builddir)/src
+
+SUBDIRS=
+
+noinst_LTLIBRARIES=libvscpl_io_posix.la
+
+libvscpl_io_posix_la_SOURCES=   \
+        Waitable.cc             \
+        Waiter.cc               \
+        WaitableEvent.cc        \
+        BufferedStream.cc       \
+        ReadingBuffer.cc        \
+        WritingBuffer.cc        \
+        Socket.cc               \
+        Connector.cc            \
+        ClientSocket.cc         \
+        LocalConnector.cc       \
+        LocalClientSocket.cc    \
+	TCPConnector.cc		\
+	TCPClientSocket.cc	\
+        Acceptor.cc             \
+	SocketAcceptor.h	\
+	ServerSocket.cc         \
+        LocalServerSocket.cc	\
+	TCPServerSocket.cc
+
+include_vscpl_io_posixdir=$(includedir)/hu/varadiistvan/scpl/io/_posix
+include_vscpl_io_posix_HEADERS= \
+        Waitable.h              \
+        Waiter.h                \
+        WaitableEvent.h         \
+        BufferedStream.h        \
+        StreamBuffer.h          \
+        ReadingBuffer.h         \
+        WritingBuffer.h         \
+        Socket.h                \
+        Connector.h             \
+        ClientSocket.h          \
+        LocalConnector.h        \
+        LocalClientSocket.h     \
+	TCPConnector.h		\
+	TCPClientSocket.h	\
+        Acceptor.h              \
+        SocketAcceptor.h        \
+        ServerSocket.h          \
+        LocalSocket.h           \
+        LocalAcceptor.h         \
+        LocalServerSocket.h     \
+        TCPSocket.h             \
+        TCPAcceptor.h           \
+	TCPServerSocket.h
Index: src/hu/varadiistvan/scpl/io/_posix/Makefile.am
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Makefile.am	(revision 32)
+++ 	(revision )
@@ -1,43 +1,0 @@
-AM_CPPFLAGS=-I$(top_builddir)/src
-
-SUBDIRS=
-
-noinst_LTLIBRARIES=libvscpl_io_posix.la
-
-libvscpl_io_posix_la_SOURCES=   \
-        Waitable.cc             \
-        Waiter.cc               \
-        WaitableEvent.cc        \
-        BufferedStream.cc       \
-        ReadingBuffer.cc        \
-        WritingBuffer.cc        \
-        Socket.cc               \
-        Connector.cc            \
-        ClientSocket.cc         \
-        LocalConnector.cc       \
-        LocalClientSocket.cc    \
-        Acceptor.cc             \
-	SocketAcceptor.h	\
-        ServerSocket.cc         \
-        LocalServerSocket.cc
-
-include_vscpl_io_posixdir=$(includedir)/hu/varadiistvan/scpl/io/_posix
-include_vscpl_io_posix_HEADERS= \
-        Waitable.h              \
-        Waiter.h                \
-        WaitableEvent.h         \
-        BufferedStream.h        \
-        StreamBuffer.h          \
-        ReadingBuffer.h         \
-        WritingBuffer.h         \
-        Socket.h                \
-        Connector.h             \
-        ClientSocket.h          \
-        LocalConnector.h        \
-        LocalClientSocket.h     \
-        Acceptor.h              \
-        SocketAcceptor.h        \
-        ServerSocket.h          \
-        LocalSocket.h           \
-        LocalAcceptor.h         \
-        LocalServerSocket.h
Index: src/hu/varadiistvan/scpl/io/_posix/ReadingBuffer.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/ReadingBuffer.cc	(revision 6)
+++ src/hu/varadiistvan/scpl/io/_posix/ReadingBuffer.cc	(revision 6)
@@ -0,0 +1,76 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "ReadingBuffer.h"
+
+#include "BufferedStream.h"
+
+#include <cassert>
+
+#include <poll.h>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::ReadingBuffer;
+
+//------------------------------------------------------------------------------
+
+bool ReadingBuffer::read()
+{
+    if (failed()) return false;
+
+    if (getLength()>0) {
+        stream.events &= ~POLLIN;
+        return true;
+    }
+
+    ssize_t result = stream.read(getData(), getCapacity());
+    if (result<0) {
+        if (stream.failed()) {
+            stream.events &= ~POLLIN;
+        } else {
+            stream.events |= POLLIN;
+        }
+    } else {
+        stream.events &= ~POLLIN;
+        size_t added = addLength(result);
+        assert(static_cast<ssize_t>(added)==result);
+        assert(static_cast<ssize_t>(getLength())==result);
+    }
+    return result>=0;
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/ReadingBuffer.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/ReadingBuffer.cc	(revision 6)
+++ 	(revision )
@@ -1,76 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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 "ReadingBuffer.h"
-
-#include "BufferedStream.h"
-
-#include <cassert>
-
-#include <poll.h>
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::io::ReadingBuffer;
-
-//------------------------------------------------------------------------------
-
-bool ReadingBuffer::read()
-{
-    if (failed()) return false;
-
-    if (getLength()>0) {
-        stream.events &= ~POLLIN;
-        return true;
-    }
-
-    ssize_t result = stream.read(getData(), getCapacity());
-    if (result<0) {
-        if (stream.failed()) {
-            stream.events &= ~POLLIN;
-        } else {
-            stream.events |= POLLIN;
-        }
-    } else {
-        stream.events &= ~POLLIN;
-        size_t added = addLength(result);
-        assert(static_cast<ssize_t>(added)==result);
-        assert(static_cast<ssize_t>(getLength())==result);
-    }
-    return result>=0;
-}
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/ReadingBuffer.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/ReadingBuffer.h	(revision 6)
+++ src/hu/varadiistvan/scpl/io/_posix/ReadingBuffer.h	(revision 6)
@@ -0,0 +1,100 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_READINGBUFFER_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_READINGBUFFER_H
+//------------------------------------------------------------------------------
+
+#include "StreamBuffer.h"
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * A buffer used for reading.
+ *
+ * It should be made empty, and then the function read() should be
+ * called on it. If it returns true, some data could be read. If the
+ * amount of data read is 0, that indicates and end-of-file condition.
+ */
+class ReadingBuffer : public StreamBuffer
+{
+protected:
+    /**
+     * Construct the buffer.
+     */
+    ReadingBuffer(size_t capacity, BufferedStream* stream);
+
+public:
+    /**
+     * Read into the buffer using the buffered stream if possible.
+     *
+     * If the buffer contains data, this function returns immediately
+     * with success, so the buffer should be reset before reading.
+     *
+     * If some data can be read immediately, that is stored in the
+     * buffer, and success is indicated. Success is indicated even if
+     * the amount of data read is 0, allowing for signalling the
+     * end-of-file or end-of-connection condition.
+     *
+     * If the reading operation would block, the stream is set up so
+     * that it would read, and failure is returned.
+     *
+     * Otherwise, if the reading operation fails for some other
+     * reason, the buffer's error code is set, so it should always be
+     * checked on a failure!
+     */
+    bool read();
+
+    friend class BufferedStream;
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline ReadingBuffer::ReadingBuffer(size_t capacity, BufferedStream* stream) :
+    StreamBuffer(capacity, stream)
+{
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_READINGBUFFER_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/ReadingBuffer.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/ReadingBuffer.h	(revision 6)
+++ 	(revision )
@@ -1,100 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_READINGBUFFER_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_READINGBUFFER_H
-//------------------------------------------------------------------------------
-
-#include "StreamBuffer.h"
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-/**
- * A buffer used for reading.
- *
- * It should be made empty, and then the function read() should be
- * called on it. If it returns true, some data could be read. If the
- * amount of data read is 0, that indicates and end-of-file condition.
- */
-class ReadingBuffer : public StreamBuffer
-{
-protected:
-    /**
-     * Construct the buffer.
-     */
-    ReadingBuffer(size_t capacity, BufferedStream* stream);
-
-public:
-    /**
-     * Read into the buffer using the buffered stream if possible.
-     *
-     * If the buffer contains data, this function returns immediately
-     * with success, so the buffer should be reset before reading.
-     *
-     * If some data can be read immediately, that is stored in the
-     * buffer, and success is indicated. Success is indicated even if
-     * the amount of data read is 0, allowing for signalling the
-     * end-of-file or end-of-connection condition.
-     *
-     * If the reading operation would block, the stream is set up so
-     * that it would read, and failure is returned.
-     *
-     * Otherwise, if the reading operation fails for some other
-     * reason, the buffer's error code is set, so it should always be
-     * checked on a failure!
-     */
-    bool read();
-
-    friend class BufferedStream;
-};
-
-//------------------------------------------------------------------------------
-// Inline definitions
-//------------------------------------------------------------------------------
-
-inline ReadingBuffer::ReadingBuffer(size_t capacity, BufferedStream* stream) :
-    StreamBuffer(capacity, stream)
-{
-}
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_READINGBUFFER_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/ServerSocket.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/ServerSocket.cc	(revision 8)
+++ src/hu/varadiistvan/scpl/io/_posix/ServerSocket.cc	(revision 8)
@@ -0,0 +1,112 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "ServerSocket.h"
+
+#include "Socket.h"
+
+#include <unistd.h>
+#include <sys/socket.h>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::ServerSocket;
+using hu::varadiistvan::scpl::io::Acceptor;
+
+//------------------------------------------------------------------------------
+
+ServerSocket::ServerSocket(int domain, int type, Waiter* waiter, int protocol) :
+    Waitable(waiter, Socket::socket(domain, type, protocol))
+{
+    if (fd<0) setErrorCodeFromErrno();
+    else if (waiter!=0) setNonBlocking(fd);
+}
+
+//------------------------------------------------------------------------------
+
+ServerSocket::~ServerSocket()
+{
+    if (fd>=0) ::close(fd);
+}
+
+//------------------------------------------------------------------------------
+
+bool ServerSocket::bind(const struct sockaddr* addr, size_t addrlen,
+                        bool reuseaddr)
+{
+    if (reuseaddr) {
+        int reuse = 1;
+        if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse))<0) {
+            setErrorCodeFromErrno();
+            return false;
+        }
+    }
+
+    if (::bind(fd, addr, addrlen)<0) {
+        setErrorCodeFromErrno();
+        return false;
+    }
+
+    return true;
+}
+
+//------------------------------------------------------------------------------
+
+bool ServerSocket::listen(int backlog)
+{
+    if (::listen(fd, backlog)<0) {
+        setErrorCodeFromErrno();
+        return false;
+    } else {
+        return true;
+    }
+}
+
+//------------------------------------------------------------------------------
+
+int ServerSocket::accept(struct sockaddr* addr, size_t* addrlen)
+{
+    socklen_t alen = (addrlen==0) ? 0 : *addrlen;
+    int result = ::accept(fd, addr, (addrlen==0) ? 0 : &alen);
+    if (result<0 && errno!=EAGAIN && errno!=EWOULDBLOCK) {
+        setErrorCodeFromErrno();
+    } else {
+        if (addrlen!=0) *addrlen = alen;
+    }
+    return result;
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/ServerSocket.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/ServerSocket.cc	(revision 8)
+++ 	(revision )
@@ -1,112 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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 "ServerSocket.h"
-
-#include "Socket.h"
-
-#include <unistd.h>
-#include <sys/socket.h>
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::io::ServerSocket;
-using hu::varadiistvan::scpl::io::Acceptor;
-
-//------------------------------------------------------------------------------
-
-ServerSocket::ServerSocket(int domain, int type, Waiter* waiter, int protocol) :
-    Waitable(waiter, Socket::socket(domain, type, protocol))
-{
-    if (fd<0) setErrorCodeFromErrno();
-    else if (waiter!=0) setNonBlocking(fd);
-}
-
-//------------------------------------------------------------------------------
-
-ServerSocket::~ServerSocket()
-{
-    if (fd>=0) ::close(fd);
-}
-
-//------------------------------------------------------------------------------
-
-bool ServerSocket::bind(const struct sockaddr* addr, size_t addrlen,
-                        bool reuseaddr)
-{
-    if (reuseaddr) {
-        int reuse = 1;
-        if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(reuse))<0) {
-            setErrorCodeFromErrno();
-            return false;
-        }
-    }
-
-    if (::bind(fd, addr, addrlen)<0) {
-        setErrorCodeFromErrno();
-        return false;
-    }
-
-    return true;
-}
-
-//------------------------------------------------------------------------------
-
-bool ServerSocket::listen(int backlog)
-{
-    if (::listen(fd, backlog)<0) {
-        setErrorCodeFromErrno();
-        return false;
-    } else {
-        return true;
-    }
-}
-
-//------------------------------------------------------------------------------
-
-int ServerSocket::accept(struct sockaddr* addr, size_t* addrlen)
-{
-    socklen_t alen = (addrlen==0) ? 0 : *addrlen;
-    int result = ::accept(fd, addr, (addrlen==0) ? 0 : &alen);
-    if (result<0 && errno!=EAGAIN && errno!=EWOULDBLOCK) {
-        setErrorCodeFromErrno();
-    } else {
-        if (addrlen!=0) *addrlen = alen;
-    }
-    return result;
-}
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/ServerSocket.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/ServerSocket.h	(revision 8)
+++ src/hu/varadiistvan/scpl/io/_posix/ServerSocket.h	(revision 8)
@@ -0,0 +1,114 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_SERVERSOCKET_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_SERVERSOCKET_H
+//------------------------------------------------------------------------------
+
+#include "Waitable.h"
+
+#include <cstdlib>
+
+//------------------------------------------------------------------------------
+
+struct sockaddr;
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+class Acceptor;
+
+//------------------------------------------------------------------------------
+
+/**
+ * A socket in a server role. It can only bind to a new address,
+ * listen and accept connections. It cannot connect to other sockets
+ * and cannot be read or written.
+ */
+class ServerSocket : public Waitable
+{
+protected:
+    /**
+     * Construct the server socket.
+     */
+    ServerSocket(int domain, int type, Waiter* waiter = 0, int protocol = 0);
+
+public:
+    /**
+     * Destroy the server socket.
+     */
+    virtual ~ServerSocket();
+
+protected:
+    /**
+     * Bind the socket to the given address.
+     *
+     * @param reuseaddr if set to true, the SO_REUSEADDR socket option
+     * will be set.
+     *
+     * @return if the binding has succeeded. If it is false, the error
+     * code will be set accordingly.
+     */
+    bool bind(const struct sockaddr* addr, size_t addrlen,
+              bool reuseaddr = true);
+
+    /**
+     * Start listening on the socket.
+     *
+     * @return if the call has succeeded. If it is false, the error
+     * code will be set accordingly.
+     */
+    bool listen(int backlog = 5);
+
+    /**
+     * Accept a socket.
+     *
+     * @return the accepted socket. If may be -1, if the socket is
+     * non-blocking, and no connection is available yet, or if another
+     * error occured, in which case the error code will be set properly.
+     */
+    int accept(struct sockaddr* addr, size_t* addrlen);
+
+    friend class Acceptor;
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_SERVERSOCKET_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/ServerSocket.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/ServerSocket.h	(revision 8)
+++ 	(revision )
@@ -1,114 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_SERVERSOCKET_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_SERVERSOCKET_H
-//------------------------------------------------------------------------------
-
-#include "Waitable.h"
-
-#include <cstdlib>
-
-//------------------------------------------------------------------------------
-
-struct sockaddr;
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-class Acceptor;
-
-//------------------------------------------------------------------------------
-
-/**
- * A socket in a server role. It can only bind to a new address,
- * listen and accept connections. It cannot connect to other sockets
- * and cannot be read or written.
- */
-class ServerSocket : public Waitable
-{
-protected:
-    /**
-     * Construct the server socket.
-     */
-    ServerSocket(int domain, int type, Waiter* waiter = 0, int protocol = 0);
-
-public:
-    /**
-     * Destroy the server socket.
-     */
-    virtual ~ServerSocket();
-
-protected:
-    /**
-     * Bind the socket to the given address.
-     *
-     * @param reuseaddr if set to true, the SO_REUSEADDR socket option
-     * will be set.
-     *
-     * @return if the binding has succeeded. If it is false, the error
-     * code will be set accordingly.
-     */
-    bool bind(const struct sockaddr* addr, size_t addrlen,
-              bool reuseaddr = true);
-
-    /**
-     * Start listening on the socket.
-     *
-     * @return if the call has succeeded. If it is false, the error
-     * code will be set accordingly.
-     */
-    bool listen(int backlog = 5);
-
-    /**
-     * Accept a socket.
-     *
-     * @return the accepted socket. If may be -1, if the socket is
-     * non-blocking, and no connection is available yet, or if another
-     * error occured, in which case the error code will be set properly.
-     */
-    int accept(struct sockaddr* addr, size_t* addrlen);
-
-    friend class Acceptor;
-};
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_SERVERSOCKET_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Socket.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Socket.cc	(revision 8)
+++ src/hu/varadiistvan/scpl/io/_posix/Socket.cc	(revision 8)
@@ -0,0 +1,60 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "Socket.h"
+
+#include <unistd.h>
+#include <sys/socket.h>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::Socket;
+
+//------------------------------------------------------------------------------
+
+int Socket::socket(int domain, int type, int protocol)
+{
+    return ::socket(domain, type, protocol);
+}
+
+//------------------------------------------------------------------------------
+
+Socket::~Socket()
+{
+    if (fd>=0) ::close(fd);
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Socket.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Socket.cc	(revision 8)
+++ 	(revision )
@@ -1,60 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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 "Socket.h"
-
-#include <unistd.h>
-#include <sys/socket.h>
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::io::Socket;
-
-//------------------------------------------------------------------------------
-
-int Socket::socket(int domain, int type, int protocol)
-{
-    return ::socket(domain, type, protocol);
-}
-
-//------------------------------------------------------------------------------
-
-Socket::~Socket()
-{
-    if (fd>=0) ::close(fd);
-}
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Socket.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Socket.h	(revision 8)
+++ src/hu/varadiistvan/scpl/io/_posix/Socket.h	(revision 8)
@@ -0,0 +1,113 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_SOCKET_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_SOCKET_H
+//------------------------------------------------------------------------------
+
+#include "BufferedStream.h"
+
+//------------------------------------------------------------------------------
+
+struct sockaddr;
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * A buffered, waitable socket implementation.
+ */
+class Socket : public BufferedStream
+{
+private:
+    /**
+     * Construct a socket with the given parameters.
+     */
+    static int socket(int domain, int type, int protocol);
+
+protected:
+    /**
+     * Construct the socket with the given parameters.
+     */
+    Socket(int domain, int type, Waiter* waiter = 0, int protocol = 0,
+           size_t readingCapacity = DEFAULT_CAPACITY,
+           size_t writingCapacity = DEFAULT_CAPACITY);
+
+    /**
+     * Construct the socket with the given file descriptor.
+     */
+    Socket(int fd, Waiter* waiter = 0,
+           size_t readingCapacity = DEFAULT_CAPACITY,
+           size_t writingCapacity = DEFAULT_CAPACITY);
+
+public:
+    /**
+     * Destroy the socket by closing the file descriptor.
+     */
+    virtual ~Socket();
+
+    friend class ServerSocket;
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline Socket::Socket(int domain, int type, Waiter* waiter, int protocol,
+                      size_t readingCapacity, size_t writingCapacity) :
+    BufferedStream(waiter, socket(domain, type, protocol),
+                     readingCapacity, writingCapacity)
+{
+    if (fd<0) setErrorCodeFromErrno();
+    else if (waiter!=0) setNonBlocking(fd);
+}
+
+//------------------------------------------------------------------------------
+
+inline Socket::Socket(int fd, Waiter* waiter,
+                      size_t readingCapacity, size_t writingCapacity) :
+    BufferedStream(waiter, fd, readingCapacity, writingCapacity)
+{
+    if (waiter!=0) setNonBlocking(fd);
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_SOCKET_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Socket.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Socket.h	(revision 8)
+++ 	(revision )
@@ -1,113 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_SOCKET_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_SOCKET_H
-//------------------------------------------------------------------------------
-
-#include "BufferedStream.h"
-
-//------------------------------------------------------------------------------
-
-struct sockaddr;
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-/**
- * A buffered, waitable socket implementation.
- */
-class Socket : public BufferedStream
-{
-private:
-    /**
-     * Construct a socket with the given parameters.
-     */
-    static int socket(int domain, int type, int protocol);
-
-protected:
-    /**
-     * Construct the socket with the given parameters.
-     */
-    Socket(int domain, int type, Waiter* waiter = 0, int protocol = 0,
-           size_t readingCapacity = DEFAULT_CAPACITY,
-           size_t writingCapacity = DEFAULT_CAPACITY);
-
-    /**
-     * Construct the socket with the given file descriptor.
-     */
-    Socket(int fd, Waiter* waiter = 0,
-           size_t readingCapacity = DEFAULT_CAPACITY,
-           size_t writingCapacity = DEFAULT_CAPACITY);
-
-public:
-    /**
-     * Destroy the socket by closing the file descriptor.
-     */
-    virtual ~Socket();
-
-    friend class ServerSocket;
-};
-
-//------------------------------------------------------------------------------
-// Inline definitions
-//------------------------------------------------------------------------------
-
-inline Socket::Socket(int domain, int type, Waiter* waiter, int protocol,
-                      size_t readingCapacity, size_t writingCapacity) :
-    BufferedStream(waiter, socket(domain, type, protocol),
-                     readingCapacity, writingCapacity)
-{
-    if (fd<0) setErrorCodeFromErrno();
-    else if (waiter!=0) setNonBlocking(fd);
-}
-
-//------------------------------------------------------------------------------
-
-inline Socket::Socket(int fd, Waiter* waiter,
-                      size_t readingCapacity, size_t writingCapacity) :
-    BufferedStream(waiter, fd, readingCapacity, writingCapacity)
-{
-    if (waiter!=0) setNonBlocking(fd);
-}
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_SOCKET_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/SocketAcceptor.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/SocketAcceptor.h	(revision 32)
+++ src/hu/varadiistvan/scpl/io/_posix/SocketAcceptor.h	(revision 32)
@@ -0,0 +1,132 @@
+// Copyright (c) 2022 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#pragma once
+
+//------------------------------------------------------------------------------
+
+#include "Acceptor.h"
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * Socket acceptor template for a certain kind of client sockets.
+ */
+template <class Socket>
+class SocketAcceptor : public Acceptor
+{
+protected:
+    /**
+     * Construct the acceptor.
+     */
+    SocketAcceptor(ServerSocket* socket);
+
+public:
+    /**
+     * Get the socket accepted last. If no socket was accepted,
+     * return 0. The socket's waiter will be the given one
+     * (which can be 0).
+     */
+    Socket* getSocket(Waiter* waiter,
+                      size_t readingCapacity = Socket::DEFAULT_CAPACITY,
+                      size_t writingCapacity = Socket::DEFAULT_CAPACITY);
+    /**
+     * Get the socket accepted last. If no socket was accepted,
+     * return 0. The socket's waiter will be the same as that of
+     * the associated server socket.
+     */
+    Socket* getSocket(size_t readingCapacity = Socket::DEFAULT_CAPACITY,
+                      size_t writingCapacity = Socket::DEFAULT_CAPACITY);
+
+    /**
+     * Get the last accepted socket as a buffered stream with the given waiter,
+     * if any.
+     */
+    BufferedStream* getAcceptedBufferedStream(Waiter* waiter = nullptr) override;
+};
+
+//------------------------------------------------------------------------------
+// Template definitions
+//------------------------------------------------------------------------------
+
+template <class Socket>
+inline SocketAcceptor<Socket>::SocketAcceptor(ServerSocket* socket) :
+    Acceptor(socket)
+{
+}
+
+//------------------------------------------------------------------------------
+
+template <class Socket>
+inline Socket*
+SocketAcceptor<Socket>::getSocket(Waiter* waiter,
+                                  size_t readingCapacity,
+                                  size_t writingCapacity)
+{
+    if (acceptedFD<0) return 0;
+
+    Socket* socket = new Socket(acceptedFD, waiter,
+                                readingCapacity, writingCapacity);
+    connectionProcessed();
+    return socket;
+}
+
+//------------------------------------------------------------------------------
+
+template <class Socket>
+inline Socket*
+SocketAcceptor<Socket>::getSocket(size_t readingCapacity,
+                                  size_t writingCapacity)
+{
+    return getSocket(socket.getWaiter(), readingCapacity, writingCapacity);
+}
+
+//------------------------------------------------------------------------------
+
+template <class Socket>
+BufferedStream* SocketAcceptor<Socket>::
+getAcceptedBufferedStream(Waiter* waiter)
+{
+    return (waiter==nullptr) ? getSocket() : getSocket(waiter);
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/SocketAcceptor.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/SocketAcceptor.h	(revision 32)
+++ 	(revision )
@@ -1,132 +1,0 @@
-// Copyright (c) 2022 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#pragma once
-
-//------------------------------------------------------------------------------
-
-#include "Acceptor.h"
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-/**
- * Socket acceptor template for a certain kind of client sockets.
- */
-template <class Socket>
-class SocketAcceptor : public Acceptor
-{
-protected:
-    /**
-     * Construct the acceptor.
-     */
-    SocketAcceptor(ServerSocket* socket);
-
-public:
-    /**
-     * Get the socket accepted last. If no socket was accepted,
-     * return 0. The socket's waiter will be the given one
-     * (which can be 0).
-     */
-    Socket* getSocket(Waiter* waiter,
-                      size_t readingCapacity = Socket::DEFAULT_CAPACITY,
-                      size_t writingCapacity = Socket::DEFAULT_CAPACITY);
-    /**
-     * Get the socket accepted last. If no socket was accepted,
-     * return 0. The socket's waiter will be the same as that of
-     * the associated server socket.
-     */
-    Socket* getSocket(size_t readingCapacity = Socket::DEFAULT_CAPACITY,
-                      size_t writingCapacity = Socket::DEFAULT_CAPACITY);
-
-    /**
-     * Get the last accepted socket as a buffered stream with the given waiter,
-     * if any.
-     */
-    BufferedStream* getAcceptedBufferedStream(Waiter* waiter = nullptr) override;
-};
-
-//------------------------------------------------------------------------------
-// Template definitions
-//------------------------------------------------------------------------------
-
-template <class Socket>
-inline SocketAcceptor<Socket>::SocketAcceptor(ServerSocket* socket) :
-    Acceptor(socket)
-{
-}
-
-//------------------------------------------------------------------------------
-
-template <class Socket>
-inline Socket*
-SocketAcceptor<Socket>::getSocket(Waiter* waiter,
-                                  size_t readingCapacity,
-                                  size_t writingCapacity)
-{
-    if (acceptedFD<0) return 0;
-
-    Socket* socket = new Socket(acceptedFD, waiter,
-                                readingCapacity, writingCapacity);
-    connectionProcessed();
-    return socket;
-}
-
-//------------------------------------------------------------------------------
-
-template <class Socket>
-inline Socket*
-SocketAcceptor<Socket>::getSocket(size_t readingCapacity,
-                                  size_t writingCapacity)
-{
-    return getSocket(socket.getWaiter(), readingCapacity, writingCapacity);
-}
-
-//------------------------------------------------------------------------------
-
-template <class Socket>
-BufferedStream* SocketAcceptor<Socket>::
-getAcceptedBufferedStream(Waiter* waiter)
-{
-    return (waiter==nullptr) ? getSocket() : getSocket(waiter);
-}
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/StreamBuffer.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/StreamBuffer.h	(revision 6)
+++ src/hu/varadiistvan/scpl/io/_posix/StreamBuffer.h	(revision 6)
@@ -0,0 +1,110 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_STREAMBUFFER_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_STREAMBUFFER_H
+//------------------------------------------------------------------------------
+
+#include "../Buffer.h"
+#include "../Failable.h"
+
+#include "BufferedStream.h"
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * Base class for buffers used by a BufferedStream.
+ */
+class StreamBuffer : public Buffer, public FailableReference<StreamBuffer>
+{
+protected:
+    /**
+     * Our buffered stream.
+     */
+    BufferedStream& stream;
+
+protected:
+    /**
+     * Construct the buffer with the given waitable.
+     */
+    StreamBuffer(size_t capacity, BufferedStream* stream);
+
+private:
+    /**
+     * Get the failable object.
+     */
+    const Failable& getFailable() const;
+
+    /**
+     * Get the failable object.
+     */
+    Failable& getFailable();
+
+    friend class FailableReference<StreamBuffer>;
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline StreamBuffer::StreamBuffer(size_t capacity, BufferedStream* stream) :
+    Buffer(capacity),
+    stream(*stream)
+{
+}
+
+//------------------------------------------------------------------------------
+
+inline const Failable& StreamBuffer::getFailable() const
+{
+    return stream;
+}
+
+//------------------------------------------------------------------------------
+
+inline Failable& StreamBuffer::getFailable()
+{
+    return stream;
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_STREAMBUFFER_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/StreamBuffer.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/StreamBuffer.h	(revision 6)
+++ 	(revision )
@@ -1,110 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_STREAMBUFFER_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_STREAMBUFFER_H
-//------------------------------------------------------------------------------
-
-#include "../Buffer.h"
-#include "../Failable.h"
-
-#include "BufferedStream.h"
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-/**
- * Base class for buffers used by a BufferedStream.
- */
-class StreamBuffer : public Buffer, public FailableReference<StreamBuffer>
-{
-protected:
-    /**
-     * Our buffered stream.
-     */
-    BufferedStream& stream;
-
-protected:
-    /**
-     * Construct the buffer with the given waitable.
-     */
-    StreamBuffer(size_t capacity, BufferedStream* stream);
-
-private:
-    /**
-     * Get the failable object.
-     */
-    const Failable& getFailable() const;
-
-    /**
-     * Get the failable object.
-     */
-    Failable& getFailable();
-
-    friend class FailableReference<StreamBuffer>;
-};
-
-//------------------------------------------------------------------------------
-// Inline definitions
-//------------------------------------------------------------------------------
-
-inline StreamBuffer::StreamBuffer(size_t capacity, BufferedStream* stream) :
-    Buffer(capacity),
-    stream(*stream)
-{
-}
-
-//------------------------------------------------------------------------------
-
-inline const Failable& StreamBuffer::getFailable() const
-{
-    return stream;
-}
-
-//------------------------------------------------------------------------------
-
-inline Failable& StreamBuffer::getFailable()
-{
-    return stream;
-}
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_STREAMBUFFER_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/TCPAcceptor.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/TCPAcceptor.h	(revision 33)
+++ src/hu/varadiistvan/scpl/io/_posix/TCPAcceptor.h	(revision 33)
@@ -0,0 +1,64 @@
+// Copyright (c) 2022 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#pragma once
+
+//------------------------------------------------------------------------------
+
+#include "SocketAcceptor.h"
+
+#include "TCPSocket.h"
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * An acceptor that provides a TCPSocket for each accepted connection
+ */
+class TCPAcceptor : public SocketAcceptor<TCPSocket>
+{
+private:
+    using SocketAcceptor<TCPSocket>::SocketAcceptor;
+
+    friend class TCPServerSocket;
+};
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/TCPClientSocket.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/TCPClientSocket.cc	(revision 33)
+++ src/hu/varadiistvan/scpl/io/_posix/TCPClientSocket.cc	(revision 33)
@@ -0,0 +1,70 @@
+// Copyright (c) 2022 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "TCPClientSocket.h"
+
+#include <cstdio>
+
+#include <arpa/inet.h>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::TCPClientSocket;
+
+//------------------------------------------------------------------------------
+
+struct in_addr TCPClientSocket::str2address(const char* addressStr)
+{
+    struct in_addr address;
+    if (inet_pton(AF_INET, addressStr, &address)<0) {
+        perror("inet_pton");
+    }
+    return address;
+}
+
+//------------------------------------------------------------------------------
+
+TCPClientSocket::TCPClientSocket(struct in_addr address, unsigned short port,
+                                 Waiter* waiter,
+                                 size_t readingCapacity,
+                                 size_t writingCapacity) :
+    ClientSocket(AF_INET, SOCK_STREAM, connector, waiter, 0,
+                 readingCapacity, writingCapacity),
+    connector(this, address, port)
+{
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/TCPClientSocket.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/TCPClientSocket.h	(revision 33)
+++ src/hu/varadiistvan/scpl/io/_posix/TCPClientSocket.h	(revision 33)
@@ -0,0 +1,130 @@
+// Copyright (c) 2022 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#pragma once
+
+//------------------------------------------------------------------------------
+
+#include "ClientSocket.h"
+
+#include "TCPConnector.h"
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * Client socket that connects to a TCP server socket.
+ *
+ * The server socket's address and port should be given.
+ */
+class TCPClientSocket : public ClientSocket
+{
+public:
+    /**
+     * Convert the given string to an address
+     */
+    static struct in_addr str2address(const char* addressStr);
+
+private:
+    /**
+     * The address to use for connecting.
+     */
+    TCPConnector connector;
+
+public:
+    /**
+     * Construct the client socket with the given address and port.
+     *
+     * @param waiter the waiter to use for waiting a possible event
+     * occuring on the socket. If given, the socket will be
+     * non-blocking. Otherwise, it will be blocking, and the connect()
+     * function of the Connector might block as well as the reading
+     * and writing buffers.
+     */
+    TCPClientSocket(struct in_addr address, unsigned short port,
+                    Waiter* waiter = 0,
+                    size_t readingCapacity = DEFAULT_CAPACITY,
+                    size_t writingCapacity = DEFAULT_CAPACITY);
+
+    /**
+     * Construct the client socket with the given address and port.
+     *
+     * @param waiter the waiter to use for waiting a possible event
+     * occuring on the socket. If given, the socket will be
+     * non-blocking. Otherwise, it will be blocking, and the connect()
+     * function of the Connector might block as well as the reading
+     * and writing buffers.
+     */
+    TCPClientSocket(const char* address, unsigned short port,
+                    Waiter* waiter = 0,
+                    size_t readingCapacity = DEFAULT_CAPACITY,
+                    size_t writingCapacity = DEFAULT_CAPACITY);
+
+    /**
+     * Get the connector for this client.
+     */
+    TCPConnector& getConnector();
+
+    friend class TCPConnector;
+};
+
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline TCPClientSocket::TCPClientSocket(const char* address, unsigned short port,
+                                        Waiter* waiter,
+                                        size_t readingCapacity,
+                                        size_t writingCapacity) :
+    TCPClientSocket(str2address(address), port, waiter,
+                    readingCapacity, writingCapacity)
+{
+}
+
+//------------------------------------------------------------------------------
+
+inline TCPConnector& TCPClientSocket::getConnector()
+{
+    return connector;
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/TCPConnector.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/TCPConnector.cc	(revision 33)
+++ src/hu/varadiistvan/scpl/io/_posix/TCPConnector.cc	(revision 33)
@@ -0,0 +1,51 @@
+// Copyright (c) 2022 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "TCPConnector.h"
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::TCPConnector;
+
+//------------------------------------------------------------------------------
+
+const struct sockaddr* TCPConnector::getAddress(size_t& addrlen)
+{
+    addrlen = sizeof(address);
+    return reinterpret_cast<const struct sockaddr*>(&address);
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/TCPConnector.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/TCPConnector.h	(revision 33)
+++ src/hu/varadiistvan/scpl/io/_posix/TCPConnector.h	(revision 33)
@@ -0,0 +1,91 @@
+// Copyright (c) 2022 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#pragma once
+
+//------------------------------------------------------------------------------
+
+#include "Connector.h"
+
+#include <netinet/in.h>
+#include <sys/socket.h>
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * The connector class used by the TCP client socket.
+ */
+class TCPConnector : public Connector
+{
+private:
+    /**
+     * The socket address to connect to.
+     */
+    struct sockaddr_in address;
+
+public:
+    /**
+     * Create the connector for the given TCP client socket.
+     */
+    TCPConnector(ClientSocket* socket,
+                 struct in_addr address, unsigned short port);
+
+protected:
+    /**
+     * Get the address.
+     */
+    virtual const struct sockaddr* getAddress(size_t& addrlen);
+
+};
+
+//------------------------------------------------------------------------------
+
+inline TCPConnector::TCPConnector(ClientSocket* socket,
+                                  struct in_addr address, unsigned short port) :
+    Connector(socket)
+{
+    this->address.sin_family = AF_INET;
+    this->address.sin_addr = address;
+    this->address.sin_port = htons(port);
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/TCPServerSocket.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/TCPServerSocket.cc	(revision 33)
+++ src/hu/varadiistvan/scpl/io/_posix/TCPServerSocket.cc	(revision 33)
@@ -0,0 +1,86 @@
+// Copyright (c) 2022 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "TCPServerSocket.h"
+
+#include <poll.h>
+
+#include <netinet/in.h>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::TCPServerSocket;
+
+//------------------------------------------------------------------------------
+
+TCPServerSocket::TCPServerSocket(unsigned short port, Waiter* waiter) :
+    ServerSocket(AF_INET, SOCK_STREAM, waiter),
+    acceptor(this)
+{
+    struct sockaddr_in sin;
+    sin.sin_family = AF_INET;
+    sin.sin_addr.s_addr = INADDR_ANY;
+    sin.sin_port = htons(port);
+
+    if (bind(reinterpret_cast<struct sockaddr*>(&sin), sizeof(sin), false)<0) {
+        setErrorCode(errno);
+        return;
+    }
+
+    if (listen()<0) {
+        setErrorCode(errno);
+        return;
+    }
+}
+
+//------------------------------------------------------------------------------
+
+bool TCPServerSocket::isReady()
+{
+    return false;
+}
+
+//------------------------------------------------------------------------------
+
+void TCPServerSocket::handleEvents(short events)
+{
+    if ((events&POLLIN)==POLLIN) {
+        acceptor.accept();
+    }
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/TCPServerSocket.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/TCPServerSocket.h	(revision 33)
+++ src/hu/varadiistvan/scpl/io/_posix/TCPServerSocket.h	(revision 33)
@@ -0,0 +1,105 @@
+// Copyright (c) 2022 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#pragma once
+
+//------------------------------------------------------------------------------
+
+#include "ServerSocket.h"
+
+#include "TCPAcceptor.h"
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * A server socket that provides a TCP access point.
+ */
+class TCPServerSocket : public ServerSocket
+{
+private:
+    /**
+     * The acceptor to use for accepting connections
+     */
+    TCPAcceptor acceptor;
+
+public:
+    /**
+     * Construct the server socket to listen at the given port.
+     *
+     * @param port the number of the port to listen at
+     * @param waiter the waiter to use for waiting a possible event
+     * occuring on the socket. If given, the socket will be
+     * non-blocking. Otherwise, it will be blocking, and the accept()
+     * function of the Acceptor might block.
+     */
+    TCPServerSocket(unsigned short port, Waiter* waiter = nullptr);
+
+    /**
+     * Get the acceptor.
+     */
+    TCPAcceptor& 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 TCPAcceptor;
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline TCPAcceptor& TCPServerSocket::getAcceptor()
+{
+    return acceptor;
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/TCPSocket.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/TCPSocket.h	(revision 33)
+++ src/hu/varadiistvan/scpl/io/_posix/TCPSocket.h	(revision 33)
@@ -0,0 +1,78 @@
+// Copyright (c) 2022 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#pragma once
+
+//------------------------------------------------------------------------------
+
+#include "Socket.h"
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * A socket that works on a TCP connection.
+ */
+class TCPSocket : public Socket
+{
+private:
+    /**
+     * Construct the socket with the given parameters.
+     */
+    TCPSocket(int fd, Waiter* waiter = 0,
+              size_t readingCapacity = DEFAULT_CAPACITY,
+              size_t writingCapacity = DEFAULT_CAPACITY);
+
+    friend class SocketAcceptor<TCPSocket>;
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline TCPSocket::TCPSocket(int fd, Waiter* waiter,
+                            size_t readingCapacity,
+                            size_t writingCapacity) :
+    Socket(fd, waiter, readingCapacity, writingCapacity)
+{
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Waitable.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Waitable.cc	(revision 6)
+++ src/hu/varadiistvan/scpl/io/_posix/Waitable.cc	(revision 6)
@@ -0,0 +1,71 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "Waitable.h"
+
+#include "Waiter.h"
+
+#include <fcntl.h>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::Waitable;
+
+//------------------------------------------------------------------------------
+
+void Waitable::setNonBlocking(int fd)
+{
+    fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
+}
+
+//------------------------------------------------------------------------------
+
+Waitable::Waitable(Waiter* waiter, int fd, short events) :
+    waiter(waiter),
+    fd(fd),
+    events(events)
+{
+    if (waiter!=0) waiter->add(this);
+}
+
+//------------------------------------------------------------------------------
+
+Waitable::~Waitable()
+{
+    if (waiter!=0) waiter->remove(this);
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Waitable.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Waitable.cc	(revision 6)
+++ 	(revision )
@@ -1,71 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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 "Waitable.h"
-
-#include "Waiter.h"
-
-#include <fcntl.h>
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::io::Waitable;
-
-//------------------------------------------------------------------------------
-
-void Waitable::setNonBlocking(int fd)
-{
-    fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK);
-}
-
-//------------------------------------------------------------------------------
-
-Waitable::Waitable(Waiter* waiter, int fd, short events) :
-    waiter(waiter),
-    fd(fd),
-    events(events)
-{
-    if (waiter!=0) waiter->add(this);
-}
-
-//------------------------------------------------------------------------------
-
-Waitable::~Waitable()
-{
-    if (waiter!=0) waiter->remove(this);
-}
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Waitable.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Waitable.h	(revision 6)
+++ src/hu/varadiistvan/scpl/io/_posix/Waitable.h	(revision 6)
@@ -0,0 +1,161 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_WAITABLE_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_WAITABLE_H
+//------------------------------------------------------------------------------
+
+#include "../Failable.h"
+
+#include <cerrno>
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+class Waiter;
+
+//------------------------------------------------------------------------------
+
+/**
+ * Base class of objects for which one can wait in a Waiter.
+ *
+ * It is basically a file descriptor.
+ */
+class Waitable : public Failable
+{
+public:
+    /**
+     * Set the given file descriptor to non-blocking.
+     */
+    static void setNonBlocking(int fd);
+
+protected:
+    /**
+     * The waiter this waitable belongs to, if any.
+     */
+    Waiter* waiter;
+
+    /**
+     * The file descriptor
+     */
+    int fd;
+
+    /**
+     * The events this waitable is interested in.
+     */
+    short events;
+
+protected:
+    /**
+     * Construct the waitable.
+     */
+    Waitable(Waiter* waiter, int fd = -1, short events = 0);
+
+public:
+    /**
+     * Destroy the waitable. It will be removed from the waiter.
+     */
+    virtual ~Waitable();
+
+    /**
+     * Get the waiter.
+     */
+    Waiter* getWaiter() const;
+
+    /**
+     * Determine if the waitable is ready or not, i.e. if there is no
+     * need to wait for it.
+     *
+     * It first checks the events. If they are 0, the waitable is
+     * ready. Then it calls isReady() and returns the result of that
+     * function.
+     */
+    bool ready();
+
+protected:
+    /**
+     * Indicate if the waitable is ready, i.e. there is no need to
+     * wait for it.
+     *
+     * Calling this function should not delete the ready
+     * indication. It should be deleted by actually processing the
+     * data.
+     */
+    virtual bool isReady() = 0;
+
+    /**
+     * Handle the given events.
+     */
+    virtual void handleEvents(short events) = 0;
+
+    /**
+     * Set the error code from errno.
+     */
+    void setErrorCodeFromErrno();
+
+    friend class Waiter;
+};
+
+//------------------------------------------------------------------------------
+// Inline defintions
+//------------------------------------------------------------------------------
+
+inline Waiter* Waitable::getWaiter() const
+{
+    return waiter;
+}
+
+//------------------------------------------------------------------------------
+
+inline bool Waitable::ready()
+{
+    return (events==0) || isReady();
+}
+
+//------------------------------------------------------------------------------
+
+inline void Waitable::setErrorCodeFromErrno()
+{
+    setErrorCode(errno);
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_WAITABLE_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Waitable.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Waitable.h	(revision 6)
+++ 	(revision )
@@ -1,161 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_WAITABLE_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_WAITABLE_H
-//------------------------------------------------------------------------------
-
-#include "../Failable.h"
-
-#include <cerrno>
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-class Waiter;
-
-//------------------------------------------------------------------------------
-
-/**
- * Base class of objects for which one can wait in a Waiter.
- *
- * It is basically a file descriptor.
- */
-class Waitable : public Failable
-{
-public:
-    /**
-     * Set the given file descriptor to non-blocking.
-     */
-    static void setNonBlocking(int fd);
-
-protected:
-    /**
-     * The waiter this waitable belongs to, if any.
-     */
-    Waiter* waiter;
-
-    /**
-     * The file descriptor
-     */
-    int fd;
-
-    /**
-     * The events this waitable is interested in.
-     */
-    short events;
-
-protected:
-    /**
-     * Construct the waitable.
-     */
-    Waitable(Waiter* waiter, int fd = -1, short events = 0);
-
-public:
-    /**
-     * Destroy the waitable. It will be removed from the waiter.
-     */
-    virtual ~Waitable();
-
-    /**
-     * Get the waiter.
-     */
-    Waiter* getWaiter() const;
-
-    /**
-     * Determine if the waitable is ready or not, i.e. if there is no
-     * need to wait for it.
-     *
-     * It first checks the events. If they are 0, the waitable is
-     * ready. Then it calls isReady() and returns the result of that
-     * function.
-     */
-    bool ready();
-
-protected:
-    /**
-     * Indicate if the waitable is ready, i.e. there is no need to
-     * wait for it.
-     *
-     * Calling this function should not delete the ready
-     * indication. It should be deleted by actually processing the
-     * data.
-     */
-    virtual bool isReady() = 0;
-
-    /**
-     * Handle the given events.
-     */
-    virtual void handleEvents(short events) = 0;
-
-    /**
-     * Set the error code from errno.
-     */
-    void setErrorCodeFromErrno();
-
-    friend class Waiter;
-};
-
-//------------------------------------------------------------------------------
-// Inline defintions
-//------------------------------------------------------------------------------
-
-inline Waiter* Waitable::getWaiter() const
-{
-    return waiter;
-}
-
-//------------------------------------------------------------------------------
-
-inline bool Waitable::ready()
-{
-    return (events==0) || isReady();
-}
-
-//------------------------------------------------------------------------------
-
-inline void Waitable::setErrorCodeFromErrno()
-{
-    setErrorCode(errno);
-}
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_WAITABLE_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/WaitableEvent.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/WaitableEvent.cc	(revision 7)
+++ src/hu/varadiistvan/scpl/io/_posix/WaitableEvent.cc	(revision 7)
@@ -0,0 +1,126 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "WaitableEvent.h"
+
+#include <poll.h>
+#include <unistd.h>
+
+#include <sys/eventfd.h>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::WaitableEvent;
+
+//------------------------------------------------------------------------------
+
+WaitableEvent::WaitableEvent(Waiter* waiter) :
+    Waitable(waiter, eventfd(0, (waiter==0) ? 0 : EFD_NONBLOCK), POLLIN),
+    fired(false)
+{
+    if (fd<0) {
+        setErrorCodeFromErrno();
+    }
+}
+
+//------------------------------------------------------------------------------
+
+WaitableEvent::~WaitableEvent()
+{
+    close(fd);
+}
+
+//------------------------------------------------------------------------------
+
+void WaitableEvent::fire()
+{
+    static const uint64_t one = 1;
+    if (write(fd, &one, sizeof(one))<0) {
+        if (errno!=EAGAIN) {
+            setErrorCodeFromErrno();
+        }
+    }
+}
+
+//------------------------------------------------------------------------------
+
+bool WaitableEvent::check()
+{
+    if (doCheck()) {
+        fired = false;
+        return true;
+    } else {
+        return false;
+    }
+}
+
+//------------------------------------------------------------------------------
+
+bool WaitableEvent::isReady()
+{
+    return fired;
+}
+
+//------------------------------------------------------------------------------
+
+void WaitableEvent::handleEvents(short events)
+{
+    if ((events&POLLIN)==POLLIN) {
+        doCheck();
+    }
+}
+
+//------------------------------------------------------------------------------
+
+bool WaitableEvent::doCheck(bool fromHandleEvents)
+{
+    if (failed()) return false;
+    if (!fromHandleEvents && fired) return true;
+
+    uint64_t value = 0;
+    if (read(fd, &value, sizeof(value))<0) {
+        if (errno!=EAGAIN) {
+            setErrorCodeFromErrno();
+        }
+    } else {
+        fired = fired || value>0;
+    }
+
+    return fired;
+}
+
+//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/WaitableEvent.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/WaitableEvent.cc	(revision 7)
+++ 	(revision )
@@ -1,126 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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 "WaitableEvent.h"
-
-#include <poll.h>
-#include <unistd.h>
-
-#include <sys/eventfd.h>
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::io::WaitableEvent;
-
-//------------------------------------------------------------------------------
-
-WaitableEvent::WaitableEvent(Waiter* waiter) :
-    Waitable(waiter, eventfd(0, (waiter==0) ? 0 : EFD_NONBLOCK), POLLIN),
-    fired(false)
-{
-    if (fd<0) {
-        setErrorCodeFromErrno();
-    }
-}
-
-//------------------------------------------------------------------------------
-
-WaitableEvent::~WaitableEvent()
-{
-    close(fd);
-}
-
-//------------------------------------------------------------------------------
-
-void WaitableEvent::fire()
-{
-    static const uint64_t one = 1;
-    if (write(fd, &one, sizeof(one))<0) {
-        if (errno!=EAGAIN) {
-            setErrorCodeFromErrno();
-        }
-    }
-}
-
-//------------------------------------------------------------------------------
-
-bool WaitableEvent::check()
-{
-    if (doCheck()) {
-        fired = false;
-        return true;
-    } else {
-        return false;
-    }
-}
-
-//------------------------------------------------------------------------------
-
-bool WaitableEvent::isReady()
-{
-    return fired;
-}
-
-//------------------------------------------------------------------------------
-
-void WaitableEvent::handleEvents(short events)
-{
-    if ((events&POLLIN)==POLLIN) {
-        doCheck();
-    }
-}
-
-//------------------------------------------------------------------------------
-
-bool WaitableEvent::doCheck(bool fromHandleEvents)
-{
-    if (failed()) return false;
-    if (!fromHandleEvents && fired) return true;
-
-    uint64_t value = 0;
-    if (read(fd, &value, sizeof(value))<0) {
-        if (errno!=EAGAIN) {
-            setErrorCodeFromErrno();
-        }
-    } else {
-        fired = fired || value>0;
-    }
-
-    return fired;
-}
-
-//------------------------------------------------------------------------------
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/WaitableEvent.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/WaitableEvent.h	(revision 7)
+++ src/hu/varadiistvan/scpl/io/_posix/WaitableEvent.h	(revision 7)
@@ -0,0 +1,107 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_WAITABLEEVENT_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_WAITABLEEVENT_H
+//------------------------------------------------------------------------------
+
+#include "Waitable.h"
+
+#include "../Failable.h"
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * An event on which one can wait with a waiter.
+ */
+class WaitableEvent : public Waitable
+{
+private:
+    /**
+     * Indicate if the event is fired.
+     */
+    volatile bool fired;
+
+public:
+    /**
+     * Construct the event.
+     */
+    WaitableEvent(Waiter* waiter = 0);
+
+    /**
+     * Destroy the event.
+     */
+    virtual ~WaitableEvent();
+
+    /**
+     * Fire the event.
+     */
+    void fire();
+
+    /**
+     * Check if the event is fired or not. If so, the fired status
+     * will be cleared.
+     */
+    bool check();
+
+protected:
+    /**
+     * Check if the event is fired or not.
+     */
+    virtual bool isReady();
+
+    /**
+     * Handle the given events.
+     */
+    virtual void handleEvents(short events);
+
+private:
+    /**
+     * Perform the real check. If we already know that we are fired,
+     * just return true. Otherwise try to read from the event fd.
+     */
+    bool doCheck(bool fromHandleEvents = false);
+};
+
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_WAITABLEEVENT_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/WaitableEvent.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/WaitableEvent.h	(revision 7)
+++ 	(revision )
@@ -1,107 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_WAITABLEEVENT_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_WAITABLEEVENT_H
-//------------------------------------------------------------------------------
-
-#include "Waitable.h"
-
-#include "../Failable.h"
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-/**
- * An event on which one can wait with a waiter.
- */
-class WaitableEvent : public Waitable
-{
-private:
-    /**
-     * Indicate if the event is fired.
-     */
-    volatile bool fired;
-
-public:
-    /**
-     * Construct the event.
-     */
-    WaitableEvent(Waiter* waiter = 0);
-
-    /**
-     * Destroy the event.
-     */
-    virtual ~WaitableEvent();
-
-    /**
-     * Fire the event.
-     */
-    void fire();
-
-    /**
-     * Check if the event is fired or not. If so, the fired status
-     * will be cleared.
-     */
-    bool check();
-
-protected:
-    /**
-     * Check if the event is fired or not.
-     */
-    virtual bool isReady();
-
-    /**
-     * Handle the given events.
-     */
-    virtual void handleEvents(short events);
-
-private:
-    /**
-     * Perform the real check. If we already know that we are fired,
-     * just return true. Otherwise try to read from the event fd.
-     */
-    bool doCheck(bool fromHandleEvents = false);
-};
-
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_WAITABLEEVENT_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Waiter.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Waiter.cc	(revision 6)
+++ src/hu/varadiistvan/scpl/io/_posix/Waiter.cc	(revision 6)
@@ -0,0 +1,153 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "Waiter.h"
+
+#include "Waitable.h"
+
+#include <cassert>
+#include <cerrno>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::Waiter;
+
+//------------------------------------------------------------------------------
+
+inline bool Waiter::hasReady() const
+{
+    for(waitables_t::const_iterator i = waitables.begin(); i!=waitables.end();
+        ++i)
+    {
+        Waitable* waitable = i->second;
+        if (waitable->ready()) {
+            return true;
+        }
+    }
+    return false;
+}
+
+//------------------------------------------------------------------------------
+
+inline size_t Waiter::setupPollFDs(pollfd* pollFDs)
+{
+    size_t numValid = 0;
+
+    for(waitables_t::const_iterator i = waitables.begin(); i!=waitables.end();
+        ++i)
+    {
+        Waitable* waitable = i->second;
+        if (waitable->events==0) continue;
+
+        pollfd& pollFD = pollFDs[numValid++];
+
+        pollFD.fd = waitable->fd;
+        pollFD.events = waitable->events;
+        pollFD.revents = 0;
+    }
+
+    return numValid;
+}
+
+//------------------------------------------------------------------------------
+
+inline void Waiter::processPollFDs(const pollfd* pollFDs, size_t size)
+{
+    for(size_t i = 0; i<size; ++i) {
+        const pollfd& pollFD = pollFDs[i];
+        if (pollFD.revents!=0) {
+            waitables_t::iterator j = waitables.find(pollFD.fd);
+            assert(j!=waitables.end());
+            Waitable* waitable = j->second;
+            waitable->handleEvents(pollFD.revents);
+        }
+    }
+}
+
+//------------------------------------------------------------------------------
+
+Waiter::~Waiter()
+{
+    for(waitables_t::iterator i = waitables.begin(); i!=waitables.end(); ++i)
+    {
+        Waitable* waitable = i->second;
+        waitable->waiter = 0;
+    }
+}
+
+//------------------------------------------------------------------------------
+
+bool Waiter::wait(int timeout)
+{
+    if (hasReady()) return true;
+
+    pollfd pollFDs[numWaitables];
+    size_t numValid = setupPollFDs(pollFDs);
+
+    int result = poll(pollFDs, numValid, timeout);
+
+    if (result<0) {
+        setErrorCode(errno);
+        return false;
+    } else if (result>0) {
+        processPollFDs(pollFDs, numValid);
+    }
+
+    return hasReady();
+}
+
+//------------------------------------------------------------------------------
+
+void Waiter::add(Waitable* waitable)
+{
+    assert(waitable->fd>=0);
+    assert(waitables.find(waitable->fd)==waitables.end());
+    waitables[waitable->fd] = waitable;
+    ++numWaitables;
+}
+
+//------------------------------------------------------------------------------
+
+void Waiter::remove(Waitable* waitable)
+{
+    assert(numWaitables>0);
+    assert(waitables.find(waitable->fd)!=waitables.end());
+    assert(waitables[waitable->fd]==waitable);
+    waitables.erase(waitable->fd);
+    --numWaitables;
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Waiter.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Waiter.cc	(revision 6)
+++ 	(revision )
@@ -1,153 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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 "Waiter.h"
-
-#include "Waitable.h"
-
-#include <cassert>
-#include <cerrno>
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::io::Waiter;
-
-//------------------------------------------------------------------------------
-
-inline bool Waiter::hasReady() const
-{
-    for(waitables_t::const_iterator i = waitables.begin(); i!=waitables.end();
-        ++i)
-    {
-        Waitable* waitable = i->second;
-        if (waitable->ready()) {
-            return true;
-        }
-    }
-    return false;
-}
-
-//------------------------------------------------------------------------------
-
-inline size_t Waiter::setupPollFDs(pollfd* pollFDs)
-{
-    size_t numValid = 0;
-
-    for(waitables_t::const_iterator i = waitables.begin(); i!=waitables.end();
-        ++i)
-    {
-        Waitable* waitable = i->second;
-        if (waitable->events==0) continue;
-
-        pollfd& pollFD = pollFDs[numValid++];
-
-        pollFD.fd = waitable->fd;
-        pollFD.events = waitable->events;
-        pollFD.revents = 0;
-    }
-
-    return numValid;
-}
-
-//------------------------------------------------------------------------------
-
-inline void Waiter::processPollFDs(const pollfd* pollFDs, size_t size)
-{
-    for(size_t i = 0; i<size; ++i) {
-        const pollfd& pollFD = pollFDs[i];
-        if (pollFD.revents!=0) {
-            waitables_t::iterator j = waitables.find(pollFD.fd);
-            assert(j!=waitables.end());
-            Waitable* waitable = j->second;
-            waitable->handleEvents(pollFD.revents);
-        }
-    }
-}
-
-//------------------------------------------------------------------------------
-
-Waiter::~Waiter()
-{
-    for(waitables_t::iterator i = waitables.begin(); i!=waitables.end(); ++i)
-    {
-        Waitable* waitable = i->second;
-        waitable->waiter = 0;
-    }
-}
-
-//------------------------------------------------------------------------------
-
-bool Waiter::wait(int timeout)
-{
-    if (hasReady()) return true;
-
-    pollfd pollFDs[numWaitables];
-    size_t numValid = setupPollFDs(pollFDs);
-
-    int result = poll(pollFDs, numValid, timeout);
-
-    if (result<0) {
-        setErrorCode(errno);
-        return false;
-    } else if (result>0) {
-        processPollFDs(pollFDs, numValid);
-    }
-
-    return hasReady();
-}
-
-//------------------------------------------------------------------------------
-
-void Waiter::add(Waitable* waitable)
-{
-    assert(waitable->fd>=0);
-    assert(waitables.find(waitable->fd)==waitables.end());
-    waitables[waitable->fd] = waitable;
-    ++numWaitables;
-}
-
-//------------------------------------------------------------------------------
-
-void Waiter::remove(Waitable* waitable)
-{
-    assert(numWaitables>0);
-    assert(waitables.find(waitable->fd)!=waitables.end());
-    assert(waitables[waitable->fd]==waitable);
-    waitables.erase(waitable->fd);
-    --numWaitables;
-}
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Waiter.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Waiter.h	(revision 6)
+++ src/hu/varadiistvan/scpl/io/_posix/Waiter.h	(revision 6)
@@ -0,0 +1,154 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_WAITER_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_WAITER_H
+//------------------------------------------------------------------------------
+
+#include "../Failable.h"
+
+#include <map>
+
+#include <cstdlib>
+
+#include <poll.h>
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+class Waitable;
+
+//------------------------------------------------------------------------------
+
+/**
+ * Class that can be used to register waitable objects and then wait
+ * for them.
+ */
+class Waiter : public Failable
+{
+private:
+    /**
+     * Type for the set of waitables.
+     */
+    typedef std::map<int, Waitable*> waitables_t;
+
+    /**
+     * The set of waitables belonging to this waiter.
+     */
+    waitables_t waitables;
+
+    /**
+     * The number of waitables.
+     */
+    size_t numWaitables;
+
+public:
+    /**
+     * Construct the waiter.
+     */
+    Waiter();
+
+    /**
+     * Destroy the waiter. All waitables that still exists will be
+     * modified to point to no waiter.
+     */
+    ~Waiter();
+
+    /**
+     * Wait for any if the waitables to become ready or until a
+     * timeout expires.
+     *
+     * If any of the waitables are ready, the function returns immediately.
+     *
+     * @return true if any of the waitables has become ready, false if
+     * the timeout occurs.
+     */
+    bool wait(int timeout = -1);
+
+protected:
+    /**
+     * Add a waitable.
+     */
+    void add(Waitable* waitable);
+
+    /**
+     * Remove a waitable.
+     */
+    void remove(Waitable* waitable);
+
+private:
+    /**
+     * Determine if any of the waitables is ready.
+     */
+    bool hasReady() const;
+
+    /**
+     * Fill the given array of poll descriptors with those file
+     * descriptors that wait for an event.
+     *
+     * @param pollFDs the file descriptor array to fill. It should
+     * contain at least as many elements as the number of waitables.
+     *
+     * @return the number of valid poll file descriptors.
+     */
+    size_t setupPollFDs(pollfd* pollFDs);
+
+    /**
+     * Process the given array of poll descriptors. For each
+     * descriptor, if its events are not 0, the handleEvents()
+     * function of the corresponding waitable is called.
+     */
+    void processPollFDs(const pollfd* pollFDs, size_t size);
+
+    friend class Waitable;
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline Waiter::Waiter() :
+    numWaitables(0)
+{
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_WAITER_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/Waiter.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/Waiter.h	(revision 6)
+++ 	(revision )
@@ -1,154 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_WAITER_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_WAITER_H
-//------------------------------------------------------------------------------
-
-#include "../Failable.h"
-
-#include <map>
-
-#include <cstdlib>
-
-#include <poll.h>
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-class Waitable;
-
-//------------------------------------------------------------------------------
-
-/**
- * Class that can be used to register waitable objects and then wait
- * for them.
- */
-class Waiter : public Failable
-{
-private:
-    /**
-     * Type for the set of waitables.
-     */
-    typedef std::map<int, Waitable*> waitables_t;
-
-    /**
-     * The set of waitables belonging to this waiter.
-     */
-    waitables_t waitables;
-
-    /**
-     * The number of waitables.
-     */
-    size_t numWaitables;
-
-public:
-    /**
-     * Construct the waiter.
-     */
-    Waiter();
-
-    /**
-     * Destroy the waiter. All waitables that still exists will be
-     * modified to point to no waiter.
-     */
-    ~Waiter();
-
-    /**
-     * Wait for any if the waitables to become ready or until a
-     * timeout expires.
-     *
-     * If any of the waitables are ready, the function returns immediately.
-     *
-     * @return true if any of the waitables has become ready, false if
-     * the timeout occurs.
-     */
-    bool wait(int timeout = -1);
-
-protected:
-    /**
-     * Add a waitable.
-     */
-    void add(Waitable* waitable);
-
-    /**
-     * Remove a waitable.
-     */
-    void remove(Waitable* waitable);
-
-private:
-    /**
-     * Determine if any of the waitables is ready.
-     */
-    bool hasReady() const;
-
-    /**
-     * Fill the given array of poll descriptors with those file
-     * descriptors that wait for an event.
-     *
-     * @param pollFDs the file descriptor array to fill. It should
-     * contain at least as many elements as the number of waitables.
-     *
-     * @return the number of valid poll file descriptors.
-     */
-    size_t setupPollFDs(pollfd* pollFDs);
-
-    /**
-     * Process the given array of poll descriptors. For each
-     * descriptor, if its events are not 0, the handleEvents()
-     * function of the corresponding waitable is called.
-     */
-    void processPollFDs(const pollfd* pollFDs, size_t size);
-
-    friend class Waitable;
-};
-
-//------------------------------------------------------------------------------
-// Inline definitions
-//------------------------------------------------------------------------------
-
-inline Waiter::Waiter() :
-    numWaitables(0)
-{
-}
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_WAITER_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/WritingBuffer.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/WritingBuffer.cc	(revision 6)
+++ src/hu/varadiistvan/scpl/io/_posix/WritingBuffer.cc	(revision 6)
@@ -0,0 +1,84 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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 "WritingBuffer.h"
+
+#include "BufferedStream.h"
+
+#include <poll.h>
+
+//------------------------------------------------------------------------------
+
+using hu::varadiistvan::scpl::io::WritingBuffer;
+
+//------------------------------------------------------------------------------
+
+void WritingBuffer::reset()
+{
+    Buffer::reset();
+    offset = 0;
+    stream.events &= ~POLLOUT;
+}
+
+//------------------------------------------------------------------------------
+
+bool WritingBuffer::write()
+{
+    if (failed()) return false;
+
+    if (getLength()<=offset) {
+        reset();
+        return true;
+    }
+
+    size_t toWrite = getLength() - offset;
+
+    ssize_t result = stream.write(getData() + offset, toWrite);
+    if (result<static_cast<ssize_t>(toWrite)) {
+        if (result<0 && stream.failed()) {
+            stream.events &= ~POLLOUT;
+        } else {
+            stream.events |= POLLOUT;
+            if (result>0) offset += result;
+        }
+        return false;
+    } else {
+        reset();
+        return true;
+    }
+}
+
+//------------------------------------------------------------------------------
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/WritingBuffer.cc
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/WritingBuffer.cc	(revision 6)
+++ 	(revision )
@@ -1,84 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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 "WritingBuffer.h"
-
-#include "BufferedStream.h"
-
-#include <poll.h>
-
-//------------------------------------------------------------------------------
-
-using hu::varadiistvan::scpl::io::WritingBuffer;
-
-//------------------------------------------------------------------------------
-
-void WritingBuffer::reset()
-{
-    Buffer::reset();
-    offset = 0;
-    stream.events &= ~POLLOUT;
-}
-
-//------------------------------------------------------------------------------
-
-bool WritingBuffer::write()
-{
-    if (failed()) return false;
-
-    if (getLength()<=offset) {
-        reset();
-        return true;
-    }
-
-    size_t toWrite = getLength() - offset;
-
-    ssize_t result = stream.write(getData() + offset, toWrite);
-    if (result<static_cast<ssize_t>(toWrite)) {
-        if (result<0 && stream.failed()) {
-            stream.events &= ~POLLOUT;
-        } else {
-            stream.events |= POLLOUT;
-            if (result>0) offset += result;
-        }
-        return false;
-    } else {
-        reset();
-        return true;
-    }
-}
-
-//------------------------------------------------------------------------------
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
Index: src/hu/varadiistvan/scpl/io/_posix/WritingBuffer.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/WritingBuffer.h	(revision 6)
+++ src/hu/varadiistvan/scpl/io/_posix/WritingBuffer.h	(revision 6)
@@ -0,0 +1,113 @@
+// Copyright (c) 2013 by István Váradi
+
+// This file is part of VSCPL, a simple cross-platform utility library
+
+// 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.
+
+#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_WRITINGBUFFER_H
+#define HU_VARADIISTVAN_SCPL_IO_POSIX_WRITINGBUFFER_H
+//------------------------------------------------------------------------------
+
+#include "StreamBuffer.h"
+
+//------------------------------------------------------------------------------
+
+namespace hu { namespace varadiistvan { namespace scpl { namespace io {
+
+//------------------------------------------------------------------------------
+
+/**
+ * A buffer used for writing.
+ *
+ * The data to write should be stored in the buffer. Then write()
+ * should be called. If it returns true, it indicates that all data
+ * has been written. In that case the buffer is automatically emptied.
+ */
+class WritingBuffer : public StreamBuffer
+{
+private:
+    /**
+     * The offset of the next byte to write.
+     */
+    size_t offset;
+
+protected:
+    /**
+     * Construct the buffer.
+     */
+    WritingBuffer(size_t capacity, BufferedStream* stream);
+
+public:
+    /**
+     * Reset the buffer. It resets the offset too.
+     */
+    void reset();
+
+    /**
+     * Write the contents of the buffer using the associated buffered
+     * stream.
+     *
+     * If the buffer is empty, the function returns indicating
+     * success.
+     *
+     * If the complete remaining contents could be written, it also indicates
+     * success, and the buffer is reset, ready to be used again.
+     *
+     * If not everything can be written and the write operation
+     * indicates that it would block, this function returns failure
+     * after the stream has been set up  to handle the corresponding
+     * poll events.
+     *
+     * Otherwise, if the writing operation fails for some other
+     * reason, the buffer's error code is set to the error's code and
+     * false is returned.
+     */
+    bool write();
+
+    friend class BufferedStream;
+};
+
+//------------------------------------------------------------------------------
+// Inline definitions
+//------------------------------------------------------------------------------
+
+inline WritingBuffer::WritingBuffer(size_t capacity, BufferedStream* stream):
+    StreamBuffer(capacity, stream),
+    offset(0)
+{
+}
+
+//------------------------------------------------------------------------------
+
+} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
+
+//------------------------------------------------------------------------------
+#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_WRITINGBUFFER_H
+
+// Local Variables:
+// mode: C++
+// c-basic-offset: 4
+// indent-tabs-mode: nil
+// End:
Index: src/hu/varadiistvan/scpl/io/_posix/WritingBuffer.h
===================================================================
--- src/hu/varadiistvan/scpl/io/_posix/WritingBuffer.h	(revision 6)
+++ 	(revision )
@@ -1,113 +1,0 @@
-// Copyright (c) 2013 by István Váradi
-
-// This file is part of VSCPL, a simple cross-platform utility library
-
-// 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.
-
-#ifndef HU_VARADIISTVAN_SCPL_IO_POSIX_WRITINGBUFFER_H
-#define HU_VARADIISTVAN_SCPL_IO_POSIX_WRITINGBUFFER_H
-//------------------------------------------------------------------------------
-
-#include "StreamBuffer.h"
-
-//------------------------------------------------------------------------------
-
-namespace hu { namespace varadiistvan { namespace scpl { namespace io {
-
-//------------------------------------------------------------------------------
-
-/**
- * A buffer used for writing.
- *
- * The data to write should be stored in the buffer. Then write()
- * should be called. If it returns true, it indicates that all data
- * has been written. In that case the buffer is automatically emptied.
- */
-class WritingBuffer : public StreamBuffer
-{
-private:
-    /**
-     * The offset of the next byte to write.
-     */
-    size_t offset;
-
-protected:
-    /**
-     * Construct the buffer.
-     */
-    WritingBuffer(size_t capacity, BufferedStream* stream);
-
-public:
-    /**
-     * Reset the buffer. It resets the offset too.
-     */
-    void reset();
-
-    /**
-     * Write the contents of the buffer using the associated buffered
-     * stream.
-     *
-     * If the buffer is empty, the function returns indicating
-     * success.
-     *
-     * If the complete remaining contents could be written, it also indicates
-     * success, and the buffer is reset, ready to be used again.
-     *
-     * If not everything can be written and the write operation
-     * indicates that it would block, this function returns failure
-     * after the stream has been set up  to handle the corresponding
-     * poll events.
-     *
-     * Otherwise, if the writing operation fails for some other
-     * reason, the buffer's error code is set to the error's code and
-     * false is returned.
-     */
-    bool write();
-
-    friend class BufferedStream;
-};
-
-//------------------------------------------------------------------------------
-// Inline definitions
-//------------------------------------------------------------------------------
-
-inline WritingBuffer::WritingBuffer(size_t capacity, BufferedStream* stream):
-    StreamBuffer(capacity, stream),
-    offset(0)
-{
-}
-
-//------------------------------------------------------------------------------
-
-} /* namespace hu::varadiistvan::scpl::io */ } /* namespace hu::varadiistvan::scpl */ } /* namespace hu::varadiistvan */ } /* namespace hu */
-
-//------------------------------------------------------------------------------
-#endif // HU_VARADIISTVAN_SCPL_IO_POSIX_WRITINGBUFFER_H
-
-// Local Variables:
-// mode: C++
-// c-basic-offset: 4
-// indent-tabs-mode: nil
-// End:
