blob: 496d540ff0401f157368c3d5ff0339070ef13dec [file] [log] [blame]
Mark Sleef5f2be42006-09-05 21:05:31 +00001#ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_
2#define _THRIFT_TRANSPORT_TSERVERSOCKET_H_ 1
Mark Sleee8540632006-05-30 09:24:40 +00003
Marc Slemkod42a2c22006-08-10 03:30:18 +00004#include "TServerTransport.h"
Marc Slemko16698852006-08-04 03:16:10 +00005#include <boost/shared_ptr.hpp>
Mark Sleee8540632006-05-30 09:24:40 +00006
Marc Slemko6f038a72006-08-03 18:58:09 +00007namespace facebook { namespace thrift { namespace transport {
8
Mark Sleee8540632006-05-30 09:24:40 +00009class TSocket;
10
11/**
12 * Server socket implementation of TServerTransport. Wrapper around a unix
13 * socket listen and accept calls.
14 *
15 * @author Mark Slee <mcslee@facebook.com>
16 */
17class TServerSocket : public TServerTransport {
18 public:
19 TServerSocket(int port);
Mark Slee29050782006-09-29 00:12:30 +000020 TServerSocket(int port, int sendTimeout, int recvTimeout);
21
Mark Sleee8540632006-05-30 09:24:40 +000022 ~TServerSocket();
23
Mark Slee29050782006-09-29 00:12:30 +000024 void setSendTimeout(int sendTimeout);
25 void setRecvTimeout(int recvTimeout);
26
Mark Slee8d7e1f62006-06-07 06:48:56 +000027 void listen();
Mark Sleee8540632006-05-30 09:24:40 +000028 void close();
29
Mark Slee8d7e1f62006-06-07 06:48:56 +000030 protected:
Marc Slemko16698852006-08-04 03:16:10 +000031 shared_ptr<TTransport> acceptImpl();
Mark Slee8d7e1f62006-06-07 06:48:56 +000032
Mark Sleee8540632006-05-30 09:24:40 +000033 private:
Mark Sleee8540632006-05-30 09:24:40 +000034 int port_;
35 int serverSocket_;
36 int acceptBacklog_;
Mark Slee29050782006-09-29 00:12:30 +000037 int sendTimeout_;
38 int recvTimeout_;
Mark Sleee8540632006-05-30 09:24:40 +000039};
40
Marc Slemko6f038a72006-08-03 18:58:09 +000041}}} // facebook::thrift::transport
42
Mark Sleef5f2be42006-09-05 21:05:31 +000043#endif // #ifndef _THRIFT_TRANSPORT_TSERVERSOCKET_H_