blob: 280ee698c8aff799c66e912b211e58ebffdc654d [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);
Bryan Duxburya18364a2010-09-28 14:36:07 +000039 TServerSocket(std::string path);
Mark Slee29050782006-09-29 00:12:30 +000040
Mark Sleee8540632006-05-30 09:24:40 +000041 ~TServerSocket();
42
Mark Slee29050782006-09-29 00:12:30 +000043 void setSendTimeout(int sendTimeout);
44 void setRecvTimeout(int recvTimeout);
45
Jake Farrell32e7b2c2011-09-14 06:19:10 +000046 void setAcceptTimeout(int accTimeout);
47
boz1ea81ce2007-05-14 23:04:33 +000048 void setRetryLimit(int retryLimit);
49 void setRetryDelay(int retryDelay);
50
Christopher Piro9cc63b52008-03-21 00:40:42 +000051 void setTcpSendBuffer(int tcpSendBuffer);
52 void setTcpRecvBuffer(int tcpRecvBuffer);
53
Mark Slee8d7e1f62006-06-07 06:48:56 +000054 void listen();
Mark Sleee8540632006-05-30 09:24:40 +000055 void close();
56
Mark Slee561b5362007-03-09 19:26:29 +000057 void interrupt();
Mark Sleea5a783f2007-03-02 19:41:08 +000058
Mark Slee8d7e1f62006-06-07 06:48:56 +000059 protected:
Mark Slee5ea15f92007-03-05 22:55:59 +000060 boost::shared_ptr<TTransport> acceptImpl();
Bryan Duxburycd9aea12011-02-22 18:12:06 +000061 virtual boost::shared_ptr<TSocket> createSocket(int client);
Mark Slee8d7e1f62006-06-07 06:48:56 +000062
Mark Sleee8540632006-05-30 09:24:40 +000063 private:
Mark Sleee8540632006-05-30 09:24:40 +000064 int port_;
Bryan Duxburya18364a2010-09-28 14:36:07 +000065 std::string path_;
Mark Sleee8540632006-05-30 09:24:40 +000066 int serverSocket_;
67 int acceptBacklog_;
Mark Slee29050782006-09-29 00:12:30 +000068 int sendTimeout_;
69 int recvTimeout_;
Jake Farrell32e7b2c2011-09-14 06:19:10 +000070 int accTimeout_;
boz1ea81ce2007-05-14 23:04:33 +000071 int retryLimit_;
72 int retryDelay_;
Christopher Piro9cc63b52008-03-21 00:40:42 +000073 int tcpSendBuffer_;
74 int tcpRecvBuffer_;
Mark Slee561b5362007-03-09 19:26:29 +000075
76 int intSock1_;
77 int intSock2_;
Mark Sleee8540632006-05-30 09:24:40 +000078};
79
T Jake Lucianib5e62212009-01-31 22:36:20 +000080}}} // apache::thrift::transport
Marc Slemko6f038a72006-08-03 18:58:09 +000081
Mark Sleef5f2be42006-09-05 21:05:31 +000082#endif // #ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_