Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add debug messages to the win32 event loop test #18

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ TEST_CASE("Wait for events")
auto serverFunction = [&mutex, &cond, &ready, &dataToSend, &boundPort]() {
SOCKET serverSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (serverSocket == INVALID_SOCKET) {
spdlog::error("Cannot create server socket");
SPDLOG_ERROR("Cannot create server socket");
}
sockaddr_in ad;
ad.sin_family = AF_INET;
Expand All @@ -138,9 +138,11 @@ TEST_CASE("Wait for events")
if (foundPort == 0)
return;

SPDLOG_INFO("server: listening on port {}", foundPort);

ret = listen(serverSocket, SOMAXCONN);
if (ret == SOCKET_ERROR) {
spdlog::error("Listen error");
SPDLOG_ERROR("Listen error: {}", WSAGetLastError());
}

// Send info to the client that we're ready
Expand All @@ -156,9 +158,14 @@ TEST_CASE("Wait for events")

if (clientSocket != INVALID_SOCKET) {
ret = send(clientSocket, dataToSend.c_str(), dataToSend.size() + 1, 0);
if (ret != SOCKET_ERROR) {
SPDLOG_INFO("Server sent {} bytes", ret);
} else {
SPDLOG_ERROR("Error while sending data: {}", WSAGetLastError());
}
closesocket(clientSocket);
} else {
spdlog::error("invalid socket from accept");
SPDLOG_ERROR("invalid socket from accept");
}
};
// Start the server
Expand Down Expand Up @@ -189,6 +196,8 @@ TEST_CASE("Wait for events")
readNotifier.triggered.connect([&dataReceived](int fd) {
char buf[128] = {};
recv(fd, buf, 128, 0);
const int recvSize = recv(fd, buf, 128, 0);
SPDLOG_INFO("socket test: received {} bytes from the server", recvSize);
dataReceived = std::string(buf);
});
loop.registerNotifier(&readNotifier);
Expand Down