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 #include "seq_packet_socket_client.h"
17 
18 #include <__config>
19 #include <iostream>
20 #include <ostream>
21 
22 namespace OHOS {
23 namespace HiviewDFX {
24 using namespace std;
Init()25 SeqPacketSocketResult SeqPacketSocketClient::Init()
26 {
27     int res = Create();
28     if (res < 0) {
29         cout << "socket creation result : " << res << std::endl;
30         return SeqPacketSocketResult::CREATE_SOCKET_FAILED;
31     }
32 
33     res = Connect();
34     if (res == -1) {
35         cout << "socket connect result : " << res << std::endl;
36         return SeqPacketSocketResult::CONNECT_FAILED;
37     }
38 
39     return SeqPacketSocketResult::CREATE_AND_CONNECTED;
40 }
41 
RecvMsg(char * buffer,unsigned int len)42 int SeqPacketSocketClient::RecvMsg(char *buffer, unsigned int len)
43 {
44     return Recv(buffer, len, 0);
45 }
46 } // namespace HiviewDFX
47 } // namespace OHOS
48