blob: b482e02fe9b2d93518b4ad94e77a8dac046c6afa [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
Marc Slemko6f038a72006-08-03 18:58:09 +000013namespace facebook { namespace thrift { namespace transport {
14
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
Mark Slee8d7e1f62006-06-07 06:48:56 +000033 void listen();
Mark Sleee8540632006-05-30 09:24:40 +000034 void close();
35
Mark Sleea5a783f2007-03-02 19:41:08 +000036 void interrupt() {
37 interrupt_ = true;
38 }
39
Mark Slee8d7e1f62006-06-07 06:48:56 +000040 protected:
Marc Slemko16698852006-08-04 03:16:10 +000041 shared_ptr<TTransport> acceptImpl();
Mark Slee8d7e1f62006-06-07 06:48:56 +000042
Mark Sleee8540632006-05-30 09:24:40 +000043 private:
Mark Sleee8540632006-05-30 09:24:40 +000044 int port_;
45 int serverSocket_;
46 int acceptBacklog_;
Mark Slee29050782006-09-29 00:12:30 +000047 int sendTimeout_;
48 int recvTimeout_;
Mark Sleea5a783f2007-03-02 19:41:08 +000049 volatile bool interrupt_;
Mark Sleee8540632006-05-30 09:24:40 +000050};
51
Marc Slemko6f038a72006-08-03 18:58:09 +000052}}} // facebook::thrift::transport
53
Mark Sleef5f2be42006-09-05 21:05:31 +000054#endif // #ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_