Untitled

mail@pastecode.io avatar
unknown
plain_text
23 days ago
749 B
5
Indexable
Never
ENetPeer* createClient(ENetHost* client, const char* host, enet_uint16 port) {
    ENetAddress address;
    ENetPeer* peer;

    enet_address_set_host(&address, host);
    address.port = port;

    peer = enet_host_connect(client, &address, 2, 0);
    if (peer == nullptr) {
        std::cerr << "No available peers for initiating an ENet connection." << std::endl;
        return nullptr;
    }
    return peer;
}

ENetHost* client = enet_host_create(nullptr, 1, 2, 0, 0);
    if (client == nullptr) {
        std::cerr << "An error occurred while trying to create the client." << std::endl;
        return EXIT_FAILURE;
    }

ENetPeer* peer = createClient(client, "127.0.0.1", 17092);
    if (peer == nullptr) {
        return EXIT_FAILURE;
    }
Leave a Comment