Files
mscclpp/test/unit/socket_tests.cc
Changho Hwang c4a5958dfc Fix hanging bootstrap issues (#100)
* Renew socket interfaces and error handling into C++ style
* Fix bootstrap hanging bugs
* Misc code cleanup

---------

Co-authored-by: Binyang Li <binyli@microsoft.com>
Co-authored-by: Saeed Maleki <saemal@microsoft.com>
2023-06-15 11:29:49 +08:00

29 lines
581 B
C++

#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";
mscclppSocketAddress listenAddr;
ASSERT_NO_THROW(mscclppSocketGetAddrFromString(&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();
}