#include #include int main() { if (enet_initialize() != 0) { std::cout << "Error" << std::endl; return EXIT_FAILURE; } ENetHost* client; ENetAddress address; ENetEvent enet_event; ENetPeer* peer; client = enet_host_create(NULL, 1, 1, 0, 0); if (client == NULL) { std::cout << "Cannot create client" << std::endl; exit(EXIT_FAILURE); } // connect to server enet_address_set_host(&address, "localhost"); address.port = 1234; // init the connection peer = enet_host_connect(client, &address, 1, 0); if (peer == NULL) { std::cout << "Cannot connect" << std::endl; exit(EXIT_FAILURE); } // start connect (attemp in 5 secs) if (enet_host_service(client, &enet_event, 5000) > 0) { if (enet_event.type == ENET_EVENT_TYPE_CONNECT) { std::cout << "Connected to " << enet_event.peer->address.host << ":" << enet_event.peer->address.port << std::endl; } } else { enet_peer_reset(peer); std::cout << "Connect failed :(" << std::endl; } enet_host_destroy(client); atexit(enet_deinitialize); getchar(); return 0; }