CppCMS
basic_socket.h
1 //
2 // Copyright (C) 2009-2012 Artyom Beilis (Tonkikh)
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //
8 #ifndef BOOSTER_AIO_BASIC_SOCKET_H
9 #define BOOSTER_AIO_BASIC_SOCKET_H
10 
11 #include <booster/aio/types.h>
12 #include <booster/hold_ptr.h>
13 #include <booster/noncopyable.h>
14 #include <booster/aio/endpoint.h>
15 #include <booster/aio/basic_io_device.h>
16 
17 namespace booster {
18 namespace aio {
19 
20  class io_service;
21 
22 
26  class BOOSTER_API basic_socket : public basic_io_device {
27  public:
31  basic_socket();
36  ~basic_socket();
37 
43  void open(family_type d,socket_type t);
49  void open(family_type d,socket_type t,system::error_code &e);
50 
56  endpoint local_endpoint(system::error_code &e);
62  endpoint local_endpoint();
63 
69  endpoint remote_endpoint(system::error_code &e);
75  endpoint remote_endpoint();
76 
80  typedef enum {
81  tcp_no_delay, //< TCP_NODELAY options - disables Nagle's algorithm
82  keep_alive, //< SO_KEEPALIVE socket option
83  reuse_address //< SO_REUSEADDR socket option
84  } boolean_option_type;
85 
91  bool get_option(boolean_option_type opt,system::error_code &e);
96  bool get_option(boolean_option_type opt);
102  void set_option(boolean_option_type opt,bool v,system::error_code &e);
108  void set_option(boolean_option_type opt,bool v);
109 
110  private:
111  struct data;
112  hold_ptr<data> d;
113  };
114 
115 } // aio
116 } // booster
117 
118 #endif
This is a basic object that allows execution of asynchronous operations.
Definition: basic_io_device.h:36
this class represents the connection endpoint, that is generally sockaddr structure in Berkeley socke...
Definition: endpoint.h:26
This class represents a basic Socket object.
Definition: basic_socket.h:26
socket_type
Definition: types.h:77
The lightweight object that carries a error code information and its category.
Definition: system_error.h:83
family_type
Definition: types.h:68
this is the central event loop that dispatches all requests.
Definition: io_service.h:37