blob: b6bafa0fec761d0e55c0a99ed99ea4d9316704bb [file] [log] [blame]
Mark Slee9f0c6512007-02-28 23:58:26 +00001// 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 Sleef5f2be42006-09-05 21:05:31 +00007#ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_
8#define _THRIFT_TRANSPORT_TSERVERSOCKET_H_ 1
Mark Sleee8540632006-05-30 09:24:40 +00009
Marc Slemkod42a2c22006-08-10 03:30:18 +000010#include "TServerTransport.h"
Marc Slemko16698852006-08-04 03:16:10 +000011#include <boost/shared_ptr.hpp>
Mark Sleee8540632006-05-30 09:24:40 +000012
David Reiss0c90f6f2008-02-06 22:18:40 +000013namespace facebook { namespace thrift { namespace transport {
Marc Slemko6f038a72006-08-03 18:58:09 +000014
Mark Sleee8540632006-05-30 09:24:40 +000015class 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 */
23class TServerSocket : public TServerTransport {
24 public:
25 TServerSocket(int port);
Mark Slee29050782006-09-29 00:12:30 +000026 TServerSocket(int port, int sendTimeout, int recvTimeout);
27
Mark Sleee8540632006-05-30 09:24:40 +000028 ~TServerSocket();
29
Mark Slee29050782006-09-29 00:12:30 +000030 void setSendTimeout(int sendTimeout);
31 void setRecvTimeout(int recvTimeout);
32
boz1ea81ce2007-05-14 23:04:33 +000033 void setRetryLimit(int retryLimit);
34 void setRetryDelay(int retryDelay);
35
Christopher Piro9cc63b52008-03-21 00:40:42 +000036 void setTcpSendBuffer(int tcpSendBuffer);
37 void setTcpRecvBuffer(int tcpRecvBuffer);
38
Mark Slee8d7e1f62006-06-07 06:48:56 +000039 void listen();
Mark Sleee8540632006-05-30 09:24:40 +000040 void close();
41
Mark Slee561b5362007-03-09 19:26:29 +000042 void interrupt();
Mark Sleea5a783f2007-03-02 19:41:08 +000043
Mark Slee8d7e1f62006-06-07 06:48:56 +000044 protected:
Mark Slee5ea15f92007-03-05 22:55:59 +000045 boost::shared_ptr<TTransport> acceptImpl();
Mark Slee8d7e1f62006-06-07 06:48:56 +000046
Mark Sleee8540632006-05-30 09:24:40 +000047 private:
Mark Sleee8540632006-05-30 09:24:40 +000048 int port_;
49 int serverSocket_;
50 int acceptBacklog_;
Mark Slee29050782006-09-29 00:12:30 +000051 int sendTimeout_;
52 int recvTimeout_;
boz1ea81ce2007-05-14 23:04:33 +000053 int retryLimit_;
54 int retryDelay_;
Christopher Piro9cc63b52008-03-21 00:40:42 +000055 int tcpSendBuffer_;
56 int tcpRecvBuffer_;
Mark Slee561b5362007-03-09 19:26:29 +000057
58 int intSock1_;
59 int intSock2_;
Mark Sleee8540632006-05-30 09:24:40 +000060};
61
Marc Slemko6f038a72006-08-03 18:58:09 +000062}}} // facebook::thrift::transport
63
Mark Sleef5f2be42006-09-05 21:05:31 +000064#endif // #ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_