blob: a6be017377b3db50299329089fc498b0c8b71cb4 [file] [log] [blame]
David Reissea2cba82009-03-30 21:35:00 +00001/*
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 Slee9f0c6512007-02-28 23:58:26 +000019
Mark Sleef5f2be42006-09-05 21:05:31 +000020#ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_
21#define _THRIFT_TRANSPORT_TSERVERSOCKET_H_ 1
Mark Sleee8540632006-05-30 09:24:40 +000022
Marc Slemkod42a2c22006-08-10 03:30:18 +000023#include "TServerTransport.h"
Marc Slemko16698852006-08-04 03:16:10 +000024#include <boost/shared_ptr.hpp>
Mark Sleee8540632006-05-30 09:24:40 +000025
T Jake Lucianib5e62212009-01-31 22:36:20 +000026namespace apache { namespace thrift { namespace transport {
Marc Slemko6f038a72006-08-03 18:58:09 +000027
Mark Sleee8540632006-05-30 09:24:40 +000028class TSocket;
29
30/**
31 * Server socket implementation of TServerTransport. Wrapper around a unix
32 * socket listen and accept calls.
33 *
Mark Sleee8540632006-05-30 09:24:40 +000034 */
35class TServerSocket : public TServerTransport {
36 public:
37 TServerSocket(int port);
Mark Slee29050782006-09-29 00:12:30 +000038 TServerSocket(int port, int sendTimeout, int recvTimeout);
39
Mark Sleee8540632006-05-30 09:24:40 +000040 ~TServerSocket();
41
Mark Slee29050782006-09-29 00:12:30 +000042 void setSendTimeout(int sendTimeout);
43 void setRecvTimeout(int recvTimeout);
44
boz1ea81ce2007-05-14 23:04:33 +000045 void setRetryLimit(int retryLimit);
46 void setRetryDelay(int retryDelay);
47
Christopher Piro9cc63b52008-03-21 00:40:42 +000048 void setTcpSendBuffer(int tcpSendBuffer);
49 void setTcpRecvBuffer(int tcpRecvBuffer);
50
Mark Slee8d7e1f62006-06-07 06:48:56 +000051 void listen();
Mark Sleee8540632006-05-30 09:24:40 +000052 void close();
53
Mark Slee561b5362007-03-09 19:26:29 +000054 void interrupt();
Mark Sleea5a783f2007-03-02 19:41:08 +000055
Mark Slee8d7e1f62006-06-07 06:48:56 +000056 protected:
Mark Slee5ea15f92007-03-05 22:55:59 +000057 boost::shared_ptr<TTransport> acceptImpl();
Mark Slee8d7e1f62006-06-07 06:48:56 +000058
Mark Sleee8540632006-05-30 09:24:40 +000059 private:
Mark Sleee8540632006-05-30 09:24:40 +000060 int port_;
61 int serverSocket_;
62 int acceptBacklog_;
Mark Slee29050782006-09-29 00:12:30 +000063 int sendTimeout_;
64 int recvTimeout_;
boz1ea81ce2007-05-14 23:04:33 +000065 int retryLimit_;
66 int retryDelay_;
Christopher Piro9cc63b52008-03-21 00:40:42 +000067 int tcpSendBuffer_;
68 int tcpRecvBuffer_;
Mark Slee561b5362007-03-09 19:26:29 +000069
70 int intSock1_;
71 int intSock2_;
Mark Sleee8540632006-05-30 09:24:40 +000072};
73
T Jake Lucianib5e62212009-01-31 22:36:20 +000074}}} // apache::thrift::transport
Marc Slemko6f038a72006-08-03 18:58:09 +000075
Mark Sleef5f2be42006-09-05 21:05:31 +000076#endif // #ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_