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