1 /*
2  * Copyright (C) 2021 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef SOCKET_UTIL_H
17 #define SOCKET_UTIL_H
18 
19 #include <stdint.h>
20 
21 namespace OHOS {
22 namespace bluetooth {
23 /**
24  * @brief This SocketUtil class provides a set of methods that send
25  *        message to app.
26  */
27 class SocketUtil {
28 public:
29     /**
30      * @brief Send data to the upper app through fd.
31      *
32      * @param sock_fd socket
33      * @param buf data buffer.
34      * @param len data buffer length.
35      * @return int
36      */
37     static int SocketSendData(int sockFd, const uint8_t *buf, int len);
38 
39     /**
40      * @brief Send accept socket fd to the upper app through fd.
41      *
42      * @param sock_fd socket.
43      * @param buf data buffer.
44      * @param len data buffer length.
45      * @param int server accept fd.
46      * @return int
47      */
48     static int SocketSendFd(int sockFd, const uint8_t *buf, int len, int acceptFd);
49 };
50 }  // namespace bluetooth
51 }  // namespace OHOS
52 
53 #endif  // SOCKET_UTIL_H