Mark Slee | 9f0c651 | 2007-02-28 23:58:26 +0000 | [diff] [blame] | 1 | // Copyright (c) 2006- Facebook |
| 2 | // Distributed under the Thrift Software License |
| 3 | // |
| 4 | // See accompanying file LICENSE or visit the Thrift site at: |
| 5 | // http://developers.facebook.com/thrift/ |
| 6 | |
Mark Slee | f5f2be4 | 2006-09-05 21:05:31 +0000 | [diff] [blame] | 7 | #ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_ |
| 8 | #define _THRIFT_TRANSPORT_TSERVERSOCKET_H_ 1 |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 9 | |
Marc Slemko | d42a2c2 | 2006-08-10 03:30:18 +0000 | [diff] [blame] | 10 | #include "TServerTransport.h" |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 11 | #include <boost/shared_ptr.hpp> |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 12 | |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 13 | namespace apache { namespace thrift { namespace transport { |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 14 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 15 | class TSocket; |
| 16 | |
| 17 | /** |
| 18 | * Server socket implementation of TServerTransport. Wrapper around a unix |
| 19 | * socket listen and accept calls. |
| 20 | * |
| 21 | * @author Mark Slee <mcslee@facebook.com> |
| 22 | */ |
| 23 | class TServerSocket : public TServerTransport { |
| 24 | public: |
| 25 | TServerSocket(int port); |
Mark Slee | 2905078 | 2006-09-29 00:12:30 +0000 | [diff] [blame] | 26 | TServerSocket(int port, int sendTimeout, int recvTimeout); |
| 27 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 28 | ~TServerSocket(); |
| 29 | |
Mark Slee | 2905078 | 2006-09-29 00:12:30 +0000 | [diff] [blame] | 30 | void setSendTimeout(int sendTimeout); |
| 31 | void setRecvTimeout(int recvTimeout); |
| 32 | |
boz | 1ea81ce | 2007-05-14 23:04:33 +0000 | [diff] [blame] | 33 | void setRetryLimit(int retryLimit); |
| 34 | void setRetryDelay(int retryDelay); |
| 35 | |
Christopher Piro | 9cc63b5 | 2008-03-21 00:40:42 +0000 | [diff] [blame] | 36 | void setTcpSendBuffer(int tcpSendBuffer); |
| 37 | void setTcpRecvBuffer(int tcpRecvBuffer); |
| 38 | |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 39 | void listen(); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 40 | void close(); |
| 41 | |
Mark Slee | 561b536 | 2007-03-09 19:26:29 +0000 | [diff] [blame] | 42 | void interrupt(); |
Mark Slee | a5a783f | 2007-03-02 19:41:08 +0000 | [diff] [blame] | 43 | |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 44 | protected: |
Mark Slee | 5ea15f9 | 2007-03-05 22:55:59 +0000 | [diff] [blame] | 45 | boost::shared_ptr<TTransport> acceptImpl(); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 46 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 47 | private: |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 48 | int port_; |
| 49 | int serverSocket_; |
| 50 | int acceptBacklog_; |
Mark Slee | 2905078 | 2006-09-29 00:12:30 +0000 | [diff] [blame] | 51 | int sendTimeout_; |
| 52 | int recvTimeout_; |
boz | 1ea81ce | 2007-05-14 23:04:33 +0000 | [diff] [blame] | 53 | int retryLimit_; |
| 54 | int retryDelay_; |
Christopher Piro | 9cc63b5 | 2008-03-21 00:40:42 +0000 | [diff] [blame] | 55 | int tcpSendBuffer_; |
| 56 | int tcpRecvBuffer_; |
Mark Slee | 561b536 | 2007-03-09 19:26:29 +0000 | [diff] [blame] | 57 | |
| 58 | int intSock1_; |
| 59 | int intSock2_; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 60 | }; |
| 61 | |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 62 | }}} // apache::thrift::transport |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 63 | |
Mark Slee | f5f2be4 | 2006-09-05 21:05:31 +0000 | [diff] [blame] | 64 | #endif // #ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_ |