-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
34 changed files
with
1,948 additions
and
1,142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
85 changes: 85 additions & 0 deletions
85
include/boostconnect/application_layer/impl/socket_base.ipp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// | ||
// socket_base.ipp | ||
// ~~~~~~~~~~ | ||
// | ||
// socket_baseの実装 | ||
// | ||
|
||
#ifndef BOOSTCONNECT_APPLAYER_SOCKET_BASE_IPP | ||
#define BOOSTCONNECT_APPLAYER_SOCKET_BASE_IPP | ||
|
||
#include <boost/asio.hpp> | ||
#include <boost/bind.hpp> | ||
#include "../socket_base.hpp" | ||
|
||
namespace bstcon{ | ||
namespace application_layer{ | ||
|
||
//こいつらは無視の方針で(というかインターフェース) | ||
socket_base::socket_base(){} | ||
socket_base::~socket_base(){} | ||
|
||
template<class Socket> | ||
socket_common<Socket>::socket_common(io_service& io_service) : socket_(io_service) | ||
{ | ||
} | ||
|
||
#ifdef USE_SSL_BOOSTCONNECT | ||
template<class Socket> | ||
socket_common<Socket>::socket_common(io_service& io_service,context_type& ctx) : socket_(io_service,ctx) | ||
{ | ||
} | ||
#endif | ||
|
||
template<class Socket> | ||
socket_common<Socket>::~socket_common(){} | ||
|
||
template<class Socket> | ||
typename socket_common<Socket>::lowest_layer_type& socket_common<Socket>::lowest_layer() | ||
{ | ||
return socket_.lowest_layer(); | ||
} | ||
template<class Socket> | ||
typename socket_common<Socket>::io_service& socket_common<Socket>::get_io_service() | ||
{ | ||
return socket_.get_io_service(); | ||
} | ||
|
||
template<class Socket> | ||
std::size_t socket_common<Socket>::read_some(const mutable_buffer& buf,error_code& ec) | ||
{ | ||
return socket_.read_some(buf,ec); | ||
} | ||
template<class Socket> | ||
std::size_t socket_common<Socket>::write_some(const const_buffer& buf,error_code& ec) | ||
{ | ||
return socket_.write_some(buf,ec); | ||
} | ||
template<class Socket> | ||
std::size_t socket_common<Socket>::write_some(const consuming_buffer& buf,error_code& ec) | ||
{ | ||
return socket_.write_some(buf,ec); | ||
} | ||
template<class Socket> | ||
void socket_common<Socket>::async_read_some(const mutable_buffer& buf,ReadHandler handler) | ||
{ | ||
socket_.async_read_some(buf,handler); | ||
return; | ||
} | ||
template<class Socket> | ||
void socket_common<Socket>::async_write_some(const const_buffer& buf,WriteHandler handler) | ||
{ | ||
socket_.async_write_some(buf,handler); | ||
return; | ||
} | ||
template<class Socket> | ||
void socket_common<Socket>::async_write_some(const consuming_buffer& buf,WriteHandler handler) | ||
{ | ||
socket_.async_write_some(buf,handler); | ||
return; | ||
} | ||
|
||
} // namespace application_layer | ||
} // namespace bstcon | ||
|
||
#endif |
71 changes: 71 additions & 0 deletions
71
include/boostconnect/application_layer/impl/ssl_socket.ipp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// | ||
// ssl_socket.ipp | ||
// ~~~~~~~~~~ | ||
// | ||
// ssl_socketの実装 | ||
// | ||
|
||
#ifdef USE_SSL_BOOSTCONNECT | ||
#ifndef BOOSTCONNECT_APPLAYER_SSL_SOCKET_IPP | ||
#define BOOSTCONNECT_APPLAYER_SSL_SOCKET_IPP | ||
|
||
#include <boost/asio.hpp> | ||
#include <boost/asio/ssl.hpp> | ||
#include "../ssl_socket.hpp" | ||
|
||
namespace bstcon{ | ||
namespace application_layer{ | ||
|
||
ssl_socket::ssl_socket(io_service& io_service,context_type& ctx) : my_base(io_service,ctx) | ||
{ | ||
} | ||
ssl_socket::~ssl_socket() | ||
{ | ||
} | ||
|
||
const std::string ssl_socket::service_protocol() const | ||
{ | ||
return "https"; | ||
} | ||
|
||
//SSL通信のコネクション確立(TCPレイヤーでコネクションを行う) | ||
ssl_socket::error_code& ssl_socket::connect(endpoint_type& begin,error_code& ec) | ||
{ | ||
ec = socket_.lowest_layer().connect(begin,ec); | ||
return ec; | ||
} | ||
void ssl_socket::async_connect(endpoint_type& begin,ConnectHandler handler) | ||
{ | ||
socket_.lowest_layer().async_connect(begin,handler); | ||
return; | ||
} | ||
|
||
void ssl_socket::handshake(handshake_type type) | ||
{ | ||
socket_.handshake(type); | ||
return; | ||
} | ||
void ssl_socket::async_handshake(handshake_type type,HandshakeHandler handler) | ||
{ | ||
socket_.async_handshake(type,handler); | ||
return; | ||
} | ||
|
||
//[(SSLレイヤーの処理 ->] TCPレイヤーの処理 | ||
void ssl_socket::close() | ||
{ | ||
socket_.lowest_layer().close(); | ||
return; | ||
} | ||
void ssl_socket::shutdown(shutdown_type what) | ||
{ | ||
socket_.shutdown(); | ||
socket_.lowest_layer().shutdown(what); | ||
return; | ||
} | ||
|
||
} // namespace application_layer | ||
} // namespace bstcon | ||
|
||
#endif | ||
#endif |
77 changes: 77 additions & 0 deletions
77
include/boostconnect/application_layer/impl/tcp_socket.ipp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// | ||
// tcp_socket.ipp | ||
// ~~~~~~~~~~ | ||
// | ||
// tcp_socketの実装 | ||
// | ||
|
||
#ifndef BOOSTCONNECT_APPLAYER_TCP_SOCKET_IPP | ||
#define BOOSTCONNECT_APPLAYER_TCP_SOCKET_IPP | ||
|
||
#include <boost/asio.hpp> | ||
#include "../tcp_socket.hpp" | ||
|
||
namespace bstcon{ | ||
namespace application_layer{ | ||
|
||
tcp_socket::tcp_socket(io_service& io_service) : my_base(io_service) | ||
{ | ||
} | ||
tcp_socket::~tcp_socket(){} | ||
|
||
const std::string tcp_socket::service_protocol() const | ||
{ | ||
return "http"; | ||
} | ||
|
||
//TCP通信のコネクション確立 | ||
tcp_socket::error_code& tcp_socket::connect(endpoint_type& begin,error_code& ec) | ||
{ | ||
ec = socket_.connect(begin,ec); | ||
return ec; | ||
} | ||
void tcp_socket::async_connect(endpoint_type& begin,ConnectHandler handler) | ||
{ | ||
socket_.async_connect(begin,handler); | ||
return; | ||
} | ||
|
||
#ifdef USE_SSL_BOOSTCONNECT | ||
//TCP通信ではHandshakeを行わない -> Handlerを直接呼び出す | ||
void tcp_socket::handshake(handshake_type) | ||
{ | ||
return; | ||
} | ||
void tcp_socket::async_handshake(handshake_type,HandshakeHandler handler) | ||
{ | ||
handler(error_code()); | ||
return; | ||
} | ||
#else | ||
void tcp_socket::handshake() | ||
{ | ||
return; | ||
} | ||
void tcp_socket::async_handshake(HandshakeHandler handler) | ||
{ | ||
handler(error_code()); | ||
return; | ||
} | ||
#endif | ||
|
||
//TCPレイヤーの処理 | ||
void tcp_socket::close() | ||
{ | ||
socket_.close(); | ||
return; | ||
} | ||
void tcp_socket::shutdown(shutdown_type what) | ||
{ | ||
socket_.shutdown(what); | ||
return; | ||
} | ||
|
||
} // namespace application_layer | ||
} // namespace bstcon | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.