stream_socket.h
//
// Copyright (C) 2009-2012 Artyom Beilis (Tonkikh)
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOSTER_AIO_STREAM_SOCKET_H
#define BOOSTER_AIO_STREAM_SOCKET_H
#include <booster/aio/types.h>
#include <booster/callback.h>
#include <booster/hold_ptr.h>
#include <booster/noncopyable.h>
#include <booster/aio/endpoint.h>
#include <booster/aio/basic_io_device.h>
#include <booster/aio/basic_socket.h>
namespace booster {
namespace aio {
class mutable_buffer;
class const_buffer;
class io_service;
class BOOSTER_API stream_socket : public basic_socket {
public:
typedef enum {
shut_rd, //< Shutdown read operations
shut_wr, //< Shutdown write operations
shut_rdwr //< Shutdown both read and write operations
} how_type;
stream_socket();
stream_socket(io_service &srv);
~stream_socket();
void open(family_type d);
void open(family_type d,system::error_code &e);
void shutdown(how_type h);
void shutdown(how_type h,system::error_code &e);
void connect(endpoint const &ep);
void connect(endpoint const &ep,system::error_code &e);
void async_connect(endpoint const &ep,event_handler const &h);
size_t read_some(mutable_buffer const &buffer);
size_t read_some(mutable_buffer const &buffer,system::error_code &e);
size_t write_some(const_buffer const &buffer);
size_t write_some(const_buffer const &buffer,system::error_code &e);
size_t read(mutable_buffer const &buffer);
size_t write(const_buffer const &buffer);
size_t read(mutable_buffer const &buffer,system::error_code &e);
size_t write(const_buffer const &buffer,system::error_code &e);
void async_read_some(mutable_buffer const &buffer,io_handler const &h);
void async_write_some(const_buffer const &buffer,io_handler const &h);
void async_read(mutable_buffer const &buffer,io_handler const &h);
void async_write(const_buffer const &buffer,io_handler const &h);
private:
int readv(mutable_buffer const &b);
int writev(const_buffer const &b);
struct data;
hold_ptr<data> d;
};
BOOSTER_API void socket_pair(stream_socket &s1,stream_socket &s2,system::error_code &e);
BOOSTER_API void socket_pair(stream_socket &s1,stream_socket &s2);
} // aio
} // booster
#endif
booster::aio::endpoint
this class represents the connection endpoint, that is generally sockaddr structure in Berkeley socke...
Definition: endpoint.h:26
booster::hold_ptr< data >
booster::aio::basic_socket
This class represents a basic Socket object.
Definition: basic_socket.h:26
booster::aio::mutable_buffer
A mutable buffer - a buffer for read operations.
Definition: buffer.h:97
booster::callback
Definition: callback.h:18
booster::system::error_code
The lightweight object that carries a error code information and its category.
Definition: system_error.h:83
booster::aio::const_buffer
An immutable buffer - buffer for write operations.
Definition: buffer.h:105
booster::aio::socket_pair
BOOSTER_API void socket_pair(stream_socket &s1, stream_socket &s2, system::error_code &e)
booster::aio::family_type
family_type
Definition: types.h:68
booster::aio::stream_socket
This object represents a stream socket: TCP/IP IPv4 or IPv6 or Unix domain stream socket...
Definition: stream_socket.h:31
booster::aio::buffer
const_buffer buffer(void const *p, size_t n)
Definition: buffer.h:122
booster::aio::io_service
this is the central event loop that dispatches all requests.
Definition: io_service.h:37