forked from solidoss/solidframe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaiosecuresocket.hpp
79 lines (55 loc) · 1.92 KB
/
aiosecuresocket.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// solid/frame/aio/openssl/aiosecuresocket.hpp
//
// Copyright (c) 2015 Valentin Palade (vipalade @ gmail . com)
//
// This file is part of SolidFrame framework.
//
// 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 SOLID_FRAME_AIO_OPENSSL_SECURE_SOCKET_HPP
#define SOLID_FRAME_AIO_OPENSSL_SECURE_SOCKET_HPP
#include "solid/frame/aio/aiocommon.hpp"
#include "solid/system/socketdevice.hpp"
#include "openssl/ssl.h"
#include <cerrno>
namespace solid{
namespace frame{
namespace aio{
namespace openssl{
class Context;
class Socket{
public:
Socket(const Context &_rctx, SocketDevice &&_rsd);
Socket(const Context &_rctx);
~Socket();
SocketDevice reset(const Context &_rctx, SocketDevice &&_rsd, ErrorCodeT &_rerr);
void shutdown();
bool create(SocketAddressStub const &_rsas, ErrorCodeT &_rerr);
bool connect(SocketAddressStub const &_rsas, bool &_can_retry, ErrorCodeT &_rerr);
ErrorCodeT renegotiate();
ReactorEventsE filterReactorEvents(
const ReactorEventsE _evt
) const;
int recv(char *_pb, size_t _bl, bool &_can_retry, ErrorCodeT &_rerr);
int send(const char *_pb, size_t _bl, bool &_can_retry, ErrorCodeT &_rerr);
SocketDevice const& device()const;
SocketDevice& device();
int recvFrom(char *_pb, size_t _bl, SocketAddress &_addr, bool &_can_retry, ErrorCodeT &_rerr);
int sendTo(const char *_pb, size_t _bl, SocketAddressStub const &_rsas, bool &_can_retry, ErrorCodeT &_rerr);
bool secureAccept(bool &_can_retry, ErrorCodeT &_rerr);
bool secureConnect(bool &_can_retry, ErrorCodeT &_rerr);
bool secureShutdown(bool &_can_retry, ErrorCodeT &_rerr);
private:
SSL *pssl;
SocketDevice sd;
bool want_read_on_recv;
bool want_read_on_send;
bool want_write_on_recv;
bool want_write_on_send;
};
}//namespace openssl
}//namespace aio
}//namespace frame
}//namespace solid
#endif