1/*
2 * Copyright (c) 2024 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 <cstdio>
17#include <string>
18#include <iostream>
19
20#include "loop_event.h"
21#include "le_socket.h"
22
23int main()
24{
25    printf("请输入创建socket的类型:(pipe, tcp)\n");
26    std::string socket_type;
27    std::cin >> socket_type;
28
29    int type;
30    char *server;
31    std::string path;
32    if (socket_type == "pipe") {
33        type = TASK_STREAM | TASK_PIPE |TASK_SERVER | TASK_TEST;
34        path = "/data/testpipe";
35    } else if (socket_type == "tcp") {
36        type = TASK_STREAM | TASK_TCP |TASK_SERVER | TASK_TEST;
37        path = "127.0.0.1:7777";
38    } else {
39        printf("输入有误,请输入pipe或者tcp!");
40        system("pause");
41        return 0;
42    }
43
44    char *server = path.c_str();
45    int fd = CreateSocket(type, server);
46    if (fd == -1) {
47        printf("Create socket failed!\n");
48        system("pause");
49        return 0;
50    }
51
52    EventLoop *loop = (EventLoop *)LE_GetDefaultLoop();
53}