mirror of
https://github.com/microsoft/mscclpp.git
synced 2026-05-12 17:26:04 +00:00
* 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>
29 lines
581 B
C++
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();
|
|
}
|