MCPcopy Create free account
hub / github.com/Haivision/srt / bindSocket

Method bindSocket

test/test_reuseaddr.cpp:239–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

237 }
238
239 bool bindSocket(SRTSOCKET bindsock, std::string ip, int port, bool expect_success)
240 {
241 sockaddr_any sa = srt::CreateAddr(ip, port, AF_INET);
242
243 std::string fam = (sa.family() == AF_INET) ? "IPv4" : "IPv6";
244
245 std::cout << "[T/S] Bind @" << bindsock << " to: " << sa.str() << " (" << fam << ")" << std::endl;
246
247 int bind_res = srt_bind(bindsock, sa.get(), sa.size());
248
249 std::cout << "[T/S] ... result " << bind_res << " (expected to "
250 << (expect_success ? "succeed" : "fail") << ")\n";
251
252 if (!expect_success)
253 {
254 std::cout << "[T/S] Binding should fail: " << srt_getlasterror_str() << std::endl;
255 EXPECT_EQ(bind_res, SRT_ERROR);
256 return false;
257 }
258
259 EXPECT_NE(bind_res, SRT_ERROR);
260 return true;
261 }
262
263 bool bindListener(SRTSOCKET bindsock, std::string ip, int port, bool expect_success)
264 {

Callers

nothing calls this directly

Calls 7

srt_bindFunction · 0.85
srt_getlasterror_strFunction · 0.85
familyMethod · 0.80
CreateAddrFunction · 0.70
strMethod · 0.45
getMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected