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
85 
86 
92  bool get_option(boolean_option_type opt,system::error_code &e);
97  bool get_option(boolean_option_type opt);
103  void set_option(boolean_option_type opt,bool v,system::error_code &e);
109  void set_option(boolean_option_type opt,bool v);
110 
115  typedef enum {
116  receive_buffer_size, //< SO_RCVBUF options
117  send_buffer_size, //< SO_SNDBUF option
125  int get_option(integer_option_type opt,system::error_code &e);
131  int get_option(integer_option_type opt);
138  void set_option(integer_option_type opt,int v,system::error_code &e);
145  void set_option(integer_option_type opt,int v);
146 
153  void bind(endpoint const &ep);
160  void bind(endpoint const &ep,system::error_code &e);
166 
167  private:
168  struct data;
169  hold_ptr<data> d;
170  };
171 
172 } // aio
173 } // booster
174 
175 #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
integer_option_type
Definition: basic_socket.h:115
boolean_option_type
Definition: basic_socket.h:80
The lightweight object that carries a error code information and its category.
Definition: system_error.h:83
family_type
Definition: types.h:68
Booster library namespace. The library that implements Boost Like API in ABI backward compatible way...
Definition: application.h:23
this is the central event loop that dispatches all requests.
Definition: io_service.h:37