David Reiss | ea2cba8 | 2009-03-30 21:35:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
Mark Slee | 9f0c651 | 2007-02-28 23:58:26 +0000 | [diff] [blame] | 19 | |
Mark Slee | f5f2be4 | 2006-09-05 21:05:31 +0000 | [diff] [blame] | 20 | #ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_ |
| 21 | #define _THRIFT_TRANSPORT_TSERVERSOCKET_H_ 1 |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 22 | |
Marc Slemko | d42a2c2 | 2006-08-10 03:30:18 +0000 | [diff] [blame] | 23 | #include "TServerTransport.h" |
Marc Slemko | 1669885 | 2006-08-04 03:16:10 +0000 | [diff] [blame] | 24 | #include <boost/shared_ptr.hpp> |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 25 | |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 26 | namespace apache { namespace thrift { namespace transport { |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 27 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 28 | class TSocket; |
| 29 | |
| 30 | /** |
| 31 | * Server socket implementation of TServerTransport. Wrapper around a unix |
| 32 | * socket listen and accept calls. |
| 33 | * |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 34 | */ |
| 35 | class TServerSocket : public TServerTransport { |
| 36 | public: |
| 37 | TServerSocket(int port); |
Mark Slee | 2905078 | 2006-09-29 00:12:30 +0000 | [diff] [blame] | 38 | TServerSocket(int port, int sendTimeout, int recvTimeout); |
| 39 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 40 | ~TServerSocket(); |
| 41 | |
Mark Slee | 2905078 | 2006-09-29 00:12:30 +0000 | [diff] [blame] | 42 | void setSendTimeout(int sendTimeout); |
| 43 | void setRecvTimeout(int recvTimeout); |
| 44 | |
boz | 1ea81ce | 2007-05-14 23:04:33 +0000 | [diff] [blame] | 45 | void setRetryLimit(int retryLimit); |
| 46 | void setRetryDelay(int retryDelay); |
| 47 | |
Christopher Piro | 9cc63b5 | 2008-03-21 00:40:42 +0000 | [diff] [blame] | 48 | void setTcpSendBuffer(int tcpSendBuffer); |
| 49 | void setTcpRecvBuffer(int tcpRecvBuffer); |
| 50 | |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 51 | void listen(); |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 52 | void close(); |
| 53 | |
Mark Slee | 561b536 | 2007-03-09 19:26:29 +0000 | [diff] [blame] | 54 | void interrupt(); |
Mark Slee | a5a783f | 2007-03-02 19:41:08 +0000 | [diff] [blame] | 55 | |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 56 | protected: |
Mark Slee | 5ea15f9 | 2007-03-05 22:55:59 +0000 | [diff] [blame] | 57 | boost::shared_ptr<TTransport> acceptImpl(); |
Mark Slee | 8d7e1f6 | 2006-06-07 06:48:56 +0000 | [diff] [blame] | 58 | |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 59 | private: |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 60 | int port_; |
| 61 | int serverSocket_; |
| 62 | int acceptBacklog_; |
Mark Slee | 2905078 | 2006-09-29 00:12:30 +0000 | [diff] [blame] | 63 | int sendTimeout_; |
| 64 | int recvTimeout_; |
boz | 1ea81ce | 2007-05-14 23:04:33 +0000 | [diff] [blame] | 65 | int retryLimit_; |
| 66 | int retryDelay_; |
Christopher Piro | 9cc63b5 | 2008-03-21 00:40:42 +0000 | [diff] [blame] | 67 | int tcpSendBuffer_; |
| 68 | int tcpRecvBuffer_; |
Mark Slee | 561b536 | 2007-03-09 19:26:29 +0000 | [diff] [blame] | 69 | |
| 70 | int intSock1_; |
| 71 | int intSock2_; |
Mark Slee | e854063 | 2006-05-30 09:24:40 +0000 | [diff] [blame] | 72 | }; |
| 73 | |
T Jake Luciani | b5e6221 | 2009-01-31 22:36:20 +0000 | [diff] [blame] | 74 | }}} // apache::thrift::transport |
Marc Slemko | 6f038a7 | 2006-08-03 18:58:09 +0000 | [diff] [blame] | 75 | |
Mark Slee | f5f2be4 | 2006-09-05 21:05:31 +0000 | [diff] [blame] | 76 | #endif // #ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_ |