| 1 | /******************************************************************** |
| 2 | * Copyright (c) 2013 - 2014, Pivotal Inc. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Author: Zhanwei Wang |
| 6 | ********************************************************************/ |
| 7 | /******************************************************************** |
| 8 | * 2014 - |
| 9 | * open source under Apache License Version 2.0 |
| 10 | ********************************************************************/ |
| 11 | /** |
| 12 | * Licensed to the Apache Software Foundation (ASF) under one |
| 13 | * or more contributor license agreements. See the NOTICE file |
| 14 | * distributed with this work for additional information |
| 15 | * regarding copyright ownership. The ASF licenses this file |
| 16 | * to you under the Apache License, Version 2.0 (the |
| 17 | * "License"); you may not use this file except in compliance |
| 18 | * with the License. You may obtain a copy of the License at |
| 19 | * |
| 20 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 21 | * |
| 22 | * Unless required by applicable law or agreed to in writing, software |
| 23 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 25 | * See the License for the specific language governing permissions and |
| 26 | * limitations under the License. |
| 27 | */ |
| 28 | #ifndef _HDFS_LIBHDFS3_NETWORK_DOMAINSOCKET_H_ |
| 29 | #define _HDFS_LIBHDFS3_NETWORK_DOMAINSOCKET_H_ |
| 30 | |
| 31 | #include "TcpSocket.h" |
| 32 | |
| 33 | namespace Hdfs { |
| 34 | namespace Internal { |
| 35 | |
| 36 | /** |
| 37 | * A Domain socket client |
| 38 | */ |
| 39 | class DomainSocketImpl : public TcpSocketImpl { |
| 40 | public: |
| 41 | /** |
| 42 | * Construct a Socket object. |
| 43 | * @throw nothrow |
| 44 | */ |
| 45 | DomainSocketImpl(); |
| 46 | |
| 47 | /** |
| 48 | * Destroy a DomainSocketImpl instance. |
| 49 | */ |
| 50 | ~DomainSocketImpl(); |
| 51 | |
| 52 | /** |
| 53 | * Connection to a domain socket server. |
| 54 | * @param host The host of server. |
| 55 | * @param port The port of server. |
| 56 | * @param timeout The timeout interval of this read operation, negative |
| 57 | * means infinite. |
| 58 | * @throw HdfsNetworkException |
| 59 | * @throw HdfsTimeout |
| 60 | */ |
| 61 | void connect(const char *host, int port, int timeout); |
| 62 | |
| 63 | /** |
| 64 | * Connection to a domain socket server. |
| 65 | * @param host The host of server. |
| 66 | * @param port The port of server. |
| 67 | * @param timeout The timeout interval of this read operation, negative |
| 68 | * means infinite. |
| 69 | * @throw HdfsNetworkException |
| 70 | * @throw HdfsTimeout |
| 71 | */ |
| 72 | void connect(const char *host, const char *port, int timeout); |
| 73 | |
| 74 | /** |
| 75 | * Connection to a domain socket server. |
| 76 | * @param paddr The address of server. |
| 77 | * @param host The host of server used in error message. |
| 78 | * @param port The port of server used in error message. |
| 79 | * @param timeout The timeout interval of this read operation, negative |
| 80 | * means infinite. |
| 81 | * @throw HdfsNetworkException |
| 82 | * @throw HdfsTimeout |
| 83 | */ |
| 84 | void connect(struct addrinfo *paddr, const char *host, const char *port, |
| 85 | int timeout); |
| 86 | |
| 87 | /** |
| 88 | * Read file descriptors from domain socket. |
| 89 | * |
| 90 | * @param fds buffer to hold the received file descriptors. |
| 91 | * @param nfds number of file descriptors needs to receive. |
| 92 | * @param buffer the buffer to receive data |
| 93 | * @size buffer size to receive data |
| 94 | * |
| 95 | * @return return the number of received bytes. |
| 96 | */ |
| 97 | int32_t receiveFileDescriptors(int fds[], size_t nfds, char *buffer, |
| 98 | int32_t size); |
| 99 | }; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | #endif /* _HDFS_LIBHDFS3_NETWORK_DOMAINSOCKET_H_ */ |
| 104 | |