Files
mscclpp/test/unit/socket_tests.cc
Saeed Maleki df2f0c14ab bootstrap now takes interface (#113)
This PR fixes the issue regarding taking the interface as an input.
2023-06-29 00:16:06 +08:00

32 lines
661 B
C++

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.
#include <gtest/gtest.h>
#include <mscclpp/utils.hpp>
#include <thread>
#include "socket.h"
TEST(Socket, ListenAndConnect) {
mscclpp::Timer timeout(3);
std::string ipPortPair = "127.0.0.1:51512";
mscclpp::SocketAddress listenAddr;
ASSERT_NO_THROW(mscclpp::SocketGetAddrFromString(&listenAddr, ipPortPair.c_str()));
mscclpp::Socket listenSock(&listenAddr);
listenSock.listen();
std::thread clientThread([&listenAddr]() {
mscclpp::Socket sock(&listenAddr);
sock.connect();
});
mscclpp::Socket sock;
sock.accept(&listenSock);
clientThread.join();
}