blob: 213d9d4486fa745343f60390d13a06b78757d9f9 [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
Mark Slee8d7e1f62006-06-07 06:48:56 +000036 void listen();
Mark Sleee8540632006-05-30 09:24:40 +000037 void close();
38
Mark Slee561b5362007-03-09 19:26:29 +000039 void interrupt();
Mark Sleea5a783f2007-03-02 19:41:08 +000040
Mark Slee8d7e1f62006-06-07 06:48:56 +000041 protected:
Mark Slee5ea15f92007-03-05 22:55:59 +000042 boost::shared_ptr<TTransport> acceptImpl();
Mark Slee8d7e1f62006-06-07 06:48:56 +000043
Mark Sleee8540632006-05-30 09:24:40 +000044 private:
Mark Sleee8540632006-05-30 09:24:40 +000045 int port_;
46 int serverSocket_;
47 int acceptBacklog_;
Mark Slee29050782006-09-29 00:12:30 +000048 int sendTimeout_;
49 int recvTimeout_;
boz1ea81ce2007-05-14 23:04:33 +000050 int retryLimit_;
51 int retryDelay_;
Mark Slee561b5362007-03-09 19:26:29 +000052
53 int intSock1_;
54 int intSock2_;
Mark Sleee8540632006-05-30 09:24:40 +000055};
56
Marc Slemko6f038a72006-08-03 18:58:09 +000057}}} // facebook::thrift::transport
58
Mark Sleef5f2be42006-09-05 21:05:31 +000059#endif // #ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_