blob: 1732546ac9703ac57c39b2738ba79a5c3f81d95a [file] [log] [blame]
Roger Meierd1bf5d02012-04-11 21:38:56 +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 */
19
20#ifndef _THRIFT_TRANSPORT_TSERVERWINPIPES_H_
21#define _THRIFT_TRANSPORT_TSERVERWINPIPES_H_ 1
22#ifdef _WIN32
23
24#include "TServerTransport.h"
25#include <boost/shared_ptr.hpp>
26
27#define TPIPE_SERVER_MAX_CONNS_DEFAULT 10
28
29namespace apache { namespace thrift { namespace transport {
30
31/**
32 * Windows Pipes implementation of TServerTransport.
33 */
34class TPipeServer : public TServerTransport {
35 public:
36 //Constructors
37 // Named Pipe -
38 TPipeServer(std::string pipename, uint32_t bufsize);
39 TPipeServer(std::string pipename, uint32_t bufsize, uint32_t maxconnections);
40 TPipeServer(std::string pipename);
41 // Anonymous pipe -
42 TPipeServer(int bufsize);
43 TPipeServer();
44
45 //Destructor
46 ~TPipeServer();
47
48 //Standard transport callbacks
49 //void listen(); //Unnecessary for Windows pipes
50 void interrupt();
51 void close();
52 protected:
53 boost::shared_ptr<TTransport> acceptImpl();
54
55 bool TCreateNamedPipe();
56 bool TCreateAnonPipe();
57
58 public:
59 //Accessors
60 std::string getPipename();
61 void setPipename(std::string pipename);
62 int getBufferSize();
63 void setBufferSize(int bufsize);
64 HANDLE getPipeHandle(); //Named Pipe R/W -or- Anonymous pipe Read handle
65 HANDLE getWrtPipeHandle();
66 HANDLE getClientRdPipeHandle();
67 HANDLE getClientWrtPipeHandle();
68 bool getAnonymous();
69 void setAnonymous(bool anon);
70
71 private:
72 std::string pipename_;
73 uint32_t bufsize_;
74 uint32_t maxconns_;
75 HANDLE hPipe_; //Named Pipe (R/W) or Anonymous Pipe (R)
76 HANDLE hPipeW_; //Anonymous Pipe (W)
77 HANDLE ClientAnonRead, ClientAnonWrite; //Client side anonymous pipe handles
78 //? Do we need duplicates to send to client?
79 bool isAnonymous;
80};
81
82}}} // apache::thrift::transport
83
84#endif //_WIN32
85#endif // #ifndef _THRIFT_TRANSPORT_TSERVERWINPIPES_H_