13 #ifndef __LIBEVENT_SSL_SOCKET_HPP__
14 #define __LIBEVENT_SSL_SOCKET_HPP__
16 #include <event2/buffer.h>
17 #include <event2/bufferevent_ssl.h>
18 #include <event2/event.h>
19 #include <event2/listener.h>
20 #include <event2/util.h>
75 evconnlistener* _listener,
77 : peek_event(nullptr),
83 evconnlistener* listener;
90 RecvRequest(
char* _data,
size_t _size)
91 : data(_data), size(_size) {}
99 SendRequest(
size_t _size)
105 struct ConnectRequest
122 void accept_callback(AcceptRequest*
request);
126 static void accept_SSL_callback(AcceptRequest*
request);
131 static void peek_callback(evutil_socket_t fd,
short what,
void* arg);
138 static void recv_callback(bufferevent* bev,
void* arg);
139 void recv_callback();
141 static void send_callback(bufferevent* bev,
void* arg);
142 void send_callback();
144 static void event_callback(bufferevent* bev,
short events,
void* arg);
145 void event_callback(
short events);
149 evconnlistener* listener;
152 std::atomic_flag lock = ATOMIC_FLAG_INIT;
153 Owned<RecvRequest> recv_request;
154 Owned<SendRequest> send_request;
155 Owned<ConnectRequest> connect_request;
160 bool received_eof =
false;
181 std::weak_ptr<LibeventSSLSocketImpl>* event_loop_handle;
188 Queue<Future<std::shared_ptr<SocketImpl>>> accept_queue;
198 #endif // __LIBEVENT_SSL_SOCKET_HPP__
Try< Bytes > size(const std::string &path, const FollowSymlink follow=FollowSymlink::FOLLOW_SYMLINK)
Definition: stat.hpp:100
Future< Response > request(const Request &request, bool streamedResponse=false)
Asynchronously sends an HTTP request to the process and returns the HTTP response once the entire res...
LibeventSSLSocketImpl(int_fd _s)
int_fd s
Definition: socket.hpp:229
Kind
Available kinds of implementations.
Definition: socket.hpp:64
Future< std::shared_ptr< SocketImpl > > accept() override
Returns an implementation corresponding to the next pending connection for the listening socket...
Future< Nothing > connect(const Address &address) override
static Try< std::shared_ptr< SocketImpl > > create(int_fd s)
Definition: address.hpp:277
Try< Nothing > listen(int backlog) override
Try< Address > address() const
Returns the Address with the assigned ip and assigned port.
Try< Nothing > shutdown(int how) override
Shuts down the socket.
SocketImpl::Kind kind() const override
Definition: libevent_ssl_socket.hpp:50
Implementation interface for a Socket.
Definition: socket.hpp:55
Definition: future.hpp:73
Protocol< PromiseRequest, PromiseResponse > promise
~LibeventSSLSocketImpl() override
Result< Process > process(pid_t pid)
Definition: freebsd.hpp:30
Definition: libevent_ssl_socket.hpp:32
Future< size_t > sendfile(int_fd fd, off_t offset, size_t size) override
Try< Netlink< struct nl_sock > > socket(int protocol=NETLINK_ROUTE)
Definition: internal.hpp:91
int int_fd
Definition: int_fd.hpp:35
Future< size_t > send(const char *data, size_t size) override
Future< size_t > recv(char *data, size_t size) override