1 /*
2  * Copyright 2006 Facebook
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef _THRIFT_TRANSPORT_TSSLSERVERSOCKET_H_
8 #define _THRIFT_TRANSPORT_TSSLSERVERSOCKET_H_ 1
9 
10 #include <thrift/transport/TServerSocket.h>
11 
12 namespace apache
13 {
14 namespace thrift
15 {
16 namespace transport
17 {
18 
19 class TSSLSocketFactory;
20 
21 /**
22  * Server socket that accepts SSL connections.
23  */
24 class TSSLServerSocket : public TServerSocket
25 {
26 public:
27 	/**
28 	 * Constructor.  Binds to all interfaces.
29 	 *
30 	 * @param port    Listening port
31 	 * @param factory SSL socket factory implementation
32 	 */
33 	TSSLServerSocket(int port, std::shared_ptr<TSSLSocketFactory> factory);
34 
35 	/**
36 	 * Constructor.  Binds to the specified address.
37 	 *
38 	 * @param address Address to bind to
39 	 * @param port    Listening port
40 	 * @param factory SSL socket factory implementation
41 	 */
42 	TSSLServerSocket(const std::string &address, int port,
43 			 std::shared_ptr<TSSLSocketFactory> factory);
44 
45 	/**
46 	 * Constructor.  Binds to all interfaces.
47 	 *
48 	 * @param port        Listening port
49 	 * @param sendTimeout Socket send timeout
50 	 * @param recvTimeout Socket receive timeout
51 	 * @param factory     SSL socket factory implementation
52 	 */
53 	TSSLServerSocket(int port, int sendTimeout, int recvTimeout,
54 			 std::shared_ptr<TSSLSocketFactory> factory);
55 
56 	void listen() override;
57 	void close() override;
58 
59 protected:
60 	std::shared_ptr<TSocket> createSocket(THRIFT_SOCKET socket) override;
61 	std::shared_ptr<TSSLSocketFactory> factory_;
62 };
63 } // namespace transport
64 } // namespace thrift
65 } // namespace apache
66 
67 #endif
68