MCPcopy Create free account
hub / github.com/CobaltFusion/DebugViewPP / UdpTest

Function UdpTest

DbgMsgSrc/DbgMsgSrc.cpp:283–302  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281}
282
283void UdpTest(const std::string& address, int port)
284{
285 Win32::WinsockInitialization wsaInit;
286
287 auto s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
288 if (s == INVALID_SOCKET)
289 Win32::WSAThrowLastError("socket");
290
291 sockaddr_in sa;
292 sa.sin_family = AF_INET;
293 sa.sin_port = htons(port);
294 sa.sin_addr.s_addr = inet_addr(address.c_str());
295
296 std::string message = "DbgMsgSrc UDP message";
297 auto rc = sendto(s, message.data(), message.size(), 0, reinterpret_cast<const sockaddr*>(&sa), sizeof(sa));
298 if (rc == SOCKET_ERROR)
299 Win32::WSAThrowLastError("sendto");
300
301 closesocket(s);
302}
303
304void CoutCerrTest2()
305{

Callers 1

MainFunction · 0.85

Calls 4

dataMethod · 0.80
WSAThrowLastErrorFunction · 0.70
c_strMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected