Shadowrun: Awakened 29 September 2011 - Build 871
ThreadPoolSockets.hpp
Go to the documentation of this file.
00001 /*
00002     Copyright (c) 2009-2010 Christopher A. Taylor.  All rights reserved.
00003 
00004     Redistribution and use in source and binary forms, with or without
00005     modification, are permitted provided that the following conditions are met:
00006 
00007     * Redistributions of source code must retain the above copyright notice,
00008       this list of conditions and the following disclaimer.
00009     * Redistributions in binary form must reproduce the above copyright notice,
00010       this list of conditions and the following disclaimer in the documentation
00011       and/or other materials provided with the distribution.
00012     * Neither the name of LibCat nor the names of its contributors may be used
00013       to endorse or promote products derived from this software without
00014       specific prior written permission.
00015 
00016     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00019     ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00020     LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00021     CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00022     SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00023     INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00024     CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00025     ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00026     POSSIBILITY OF SUCH DAMAGE.
00027 */
00028 
00029 // TODO: Half-open connections can easily DoS the TCP server right now.
00030 
00031 #ifndef CAT_THREAD_POOL_SOCKETS_HPP
00032 #define CAT_THREAD_POOL_SOCKETS_HPP
00033 
00034 #include <cat/threads/ThreadPool.hpp>
00035 #include <cat/net/Sockets.hpp>
00036 
00037 namespace cat {
00038 
00039 
00040 /*
00041     Thread Pool Sockets library
00042 
00043     Provides a framework for rapidly developing TCP/UDP server and client objects
00044     that make use of high performance APIs under various server and desktop
00045     operating systems.
00046 
00047     All network events are processed by a thread pool managed by ThreadPool.
00048 */
00049 
00050 class TCPServer;
00051 class TCPConnexion;
00052 class TCPClient;
00053 class UDPEndpoint;
00054 
00055 void ReportUnexpectedSocketError(int error);
00056 
00057 
00058 } // namespace cat
00059 
00060 
00061 #if defined (CAT_OS_WINDOWS) // Windows-style IOCP
00062 
00063 #include <MSWSock.h>
00064 #include <cat/port/WindowsInclude.hpp>
00065 
00066 #include <cat/net/win/TCPServer.hpp>
00067 #include <cat/net/win/TCPConnexion.hpp>
00068 #include <cat/net/win/TCPClient.hpp>
00069 #include <cat/net/win/UDPEndpoint.hpp>
00070 
00071 #elif defined(CAT_OS_LINUX) // Linux-style eventfd
00072 
00073 #include <cat/net/linux/TCPServer.hpp>
00074 #include <cat/net/linux/TCPConnexion.hpp>
00075 #include <cat/net/linux/TCPClient.hpp>
00076 #include <cat/net/linux/UDPEndpoint.hpp>
00077 
00078 #elif defined(CAT_OS_OSX) || defined(CAT_OS_BSD) // BSD-style kevent
00079 
00080 #include <cat/net/bsd/TCPServer.hpp>
00081 #include <cat/net/bsd/TCPConnexion.hpp>
00082 #include <cat/net/bsd/TCPClient.hpp>
00083 #include <cat/net/bsd/UDPEndpoint.hpp>
00084 
00085 #else // Fall-back
00086 
00087 #include <cat/net/generic/TCPServer.hpp>
00088 #include <cat/net/generic/TCPConnexion.hpp>
00089 #include <cat/net/generic/TCPClient.hpp>
00090 #include <cat/net/generic/UDPEndpoint.hpp>
00091 
00092 #endif
00093 
00094 
00095 #endif // CAT_THREAD_POOL_SOCKETS_HPP

Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.

GNU Lesser General Public License 3 Sourceforge.net