CppCMS
booster/aio/basic_socket.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_BASIC_SOCKET_H
00009 #define BOOSTER_AIO_BASIC_SOCKET_H
00010 
00011 #include <booster/aio/types.h>
00012 #include <booster/hold_ptr.h>
00013 #include <booster/noncopyable.h>
00014 #include <booster/aio/endpoint.h>
00015 #include <booster/aio/basic_io_device.h>
00016 
00017 namespace booster {
00018 namespace aio {
00019         
00020         class io_service;
00021         
00022 
00026         class BOOSTER_API basic_socket : public basic_io_device {
00027         public:
00031                 basic_socket();
00035                 basic_socket(io_service &srv);
00036                 ~basic_socket();
00037 
00043                 void open(family_type d,socket_type t);
00049                 void open(family_type d,socket_type t,system::error_code &e);
00050 
00056                 endpoint local_endpoint(system::error_code &e);
00062                 endpoint local_endpoint();
00063 
00069                 endpoint remote_endpoint(system::error_code &e);
00075                 endpoint remote_endpoint();
00076 
00080                 typedef enum {
00081                         tcp_no_delay,   //< TCP_NODELAY options - disables Nagle's algorithm
00082                         keep_alive,     //< SO_KEEPALIVE socket option 
00083                         reuse_address   //< SO_REUSEADDR socket option
00084                 } boolean_option_type;
00085 
00091                 bool get_option(boolean_option_type opt,system::error_code &e);
00096                 bool get_option(boolean_option_type opt);
00102                 void set_option(boolean_option_type opt,bool v,system::error_code &e);
00108                 void set_option(boolean_option_type opt,bool v);
00109                 
00110         private:
00111                 struct data;
00112                 hold_ptr<data> d;
00113         };
00114 
00115 } // aio
00116 } // booster
00117 
00118 #endif