Adam Michalik | b97e2d1 | 2016-06-02 12:12:55 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | * Copyright 2016 gRPC authors. |
Adam Michalik | b97e2d1 | 2016-06-02 12:12:55 -0700 | [diff] [blame] | 4 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
Adam Michalik | b97e2d1 | 2016-06-02 12:12:55 -0700 | [diff] [blame] | 8 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
Adam Michalik | b97e2d1 | 2016-06-02 12:12:55 -0700 | [diff] [blame] | 10 | * |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
Adam Michalik | b97e2d1 | 2016-06-02 12:12:55 -0700 | [diff] [blame] | 16 | * |
| 17 | */ |
| 18 | |
Adam Michalik | b97e2d1 | 2016-06-02 12:12:55 -0700 | [diff] [blame] | 19 | #include <grpc++/channel.h> |
| 20 | #include <grpc++/create_channel.h> |
| 21 | #include <grpc++/impl/grpc_library.h> |
| 22 | #include <grpc/grpc.h> |
| 23 | #include <grpc/grpc_posix.h> |
| 24 | |
| 25 | #include "src/cpp/client/create_channel_internal.h" |
| 26 | |
| 27 | namespace grpc { |
| 28 | |
| 29 | #ifdef GPR_SUPPORT_CHANNELS_FROM_FD |
| 30 | |
Adam Michalik | 4ad746e | 2016-06-07 15:02:59 -0700 | [diff] [blame] | 31 | std::shared_ptr<Channel> CreateInsecureChannelFromFd(const grpc::string& target, |
| 32 | int fd) { |
Adam Michalik | b97e2d1 | 2016-06-02 12:12:55 -0700 | [diff] [blame] | 33 | internal::GrpcLibrary init_lib; |
| 34 | init_lib.init(); |
| 35 | return CreateChannelInternal( |
| 36 | "", grpc_insecure_channel_create_from_fd(target.c_str(), fd, nullptr)); |
| 37 | } |
| 38 | |
Adam Czachorowski | dbdc6e4 | 2016-09-09 11:32:09 +0200 | [diff] [blame] | 39 | std::shared_ptr<Channel> CreateCustomInsecureChannelFromFd( |
| 40 | const grpc::string& target, int fd, const ChannelArguments& args) { |
| 41 | internal::GrpcLibrary init_lib; |
| 42 | init_lib.init(); |
| 43 | grpc_channel_args channel_args; |
| 44 | args.SetChannelArgs(&channel_args); |
| 45 | return CreateChannelInternal("", grpc_insecure_channel_create_from_fd( |
| 46 | target.c_str(), fd, &channel_args)); |
| 47 | } |
| 48 | |
Adam Michalik | b97e2d1 | 2016-06-02 12:12:55 -0700 | [diff] [blame] | 49 | #endif // GPR_SUPPORT_CHANNELS_FROM_FD |
| 50 | |
| 51 | } // namespace grpc |