CppCMS
booster/aio/types.h
00001 //
00002 //  Copyright (C) 2009-2012 Artyom Beilis (Tonkikh)
00003 //
00004 //  Distributed under the Boost Software License, Version 1.0. (See
00005 //  accompanying file LICENSE_1_0.txt or copy at
00006 //  http://www.boost.org/LICENSE_1_0.txt)
00007 //
00008 #ifndef BOOSTER_AIO_TYPES_H
00009 #define BOOSTER_AIO_TYPES_H
00010 
00011 #include <booster/config.h>
00012 #include <stddef.h>
00013 
00014 namespace booster {
00015         template<typename F>
00016         class callback;
00017 
00018         namespace system {
00019                 class error_code;
00020         }
00021 
00022 
00027         namespace aio {
00028                 class endpoint;
00029                 class io_service;
00030 
00031                 #ifdef BOOSTER_DOXYGEN_DOCS
00032 
00033 
00034 
00035                 typedef unspecified native_type; 
00039                 static const native_type invalid_socket = unspecified;
00040 
00041                 #elif defined BOOSTER_WIN32
00042                 typedef unsigned native_type;
00043                 static const unsigned invalid_socket = (unsigned)(-1);
00044                 #else
00045                 typedef int native_type;
00046                 static const int invalid_socket = -1;
00047                 #endif
00048 
00053                 typedef callback<void(system::error_code const &)> event_handler;
00054 
00058                 typedef callback<void()> handler;
00063                 typedef callback<void(system::error_code const &,size_t)> io_handler;
00064 
00068                 typedef enum {
00069                         pf_unix,  //<  Unix domain socket
00070                         pf_inet,  //<  IPv4 socket
00071                         pf_inet6  //<  IPv6 socket
00072                 } family_type;
00073                 
00077                 typedef enum {
00078                         sock_stream,    //< Stream socket (like TCP/IP)
00079                         sock_datagram   //< Datagram socket (like UDP)
00080                 } socket_type;
00081                 
00086                 struct io_events {
00087                         static const int in   = 1 << 0; //< Event socket readability
00088                         static const int out  = 1 << 1; //< Event socket writability
00089                         static const int err  = 1 << 2; //< Error on socket or OOB data
00090                 };
00091         }
00092 } 
00093 
00094 
00095 #endif