MCPcopy Create free account
hub / github.com/defold/defold / Bind

Function Bind

engine/dlib/src/dlib/socket_win32.cpp:399–428  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

397 }
398
399 Result Bind(Socket socket, Address address, int port)
400 {
401 int result = 0;
402 if (IsSocketIPv4(socket))
403 {
404 assert(address.m_family == DOMAIN_IPV4);
405
406 struct sockaddr_in sock_addr = { 0 };
407 sock_addr.sin_family = AF_INET;
408 sock_addr.sin_addr.s_addr = *IPv4(&address);
409 sock_addr.sin_port = htons(port);
410 result = bind(socket, (struct sockaddr*)&sock_addr, sizeof(sock_addr));
411 }
412#if !defined(DM_IPV6_UNSUPPORTED)
413 else if (IsSocketIPv6(socket))
414 {
415 assert(address.m_family == DOMAIN_IPV6);
416
417 struct sockaddr_in6 sock_addr = { 0 };
418 sock_addr.sin6_family = AF_INET6;
419 memcpy(&sock_addr.sin6_addr, IPv6(&address), sizeof(struct in6_addr));
420 sock_addr.sin6_port = htons(port);
421 result = bind(socket, (struct sockaddr*)&sock_addr, sizeof(sock_addr));
422 }
423#endif // no ipv6
424 else
425 {
426 dmLogError("Failed to bind socket, unsupported address family!");
427 return RESULT_AFNOSUPPORT;
428 }
429
430 return result == 0 ? RESULT_OK : NATIVETORESULT(DM_SOCKET_ERRNO);
431 }

Callers 8

dmLogInitSocketFunction · 0.70
ConnectFunction · 0.70
CreateSocketFunction · 0.70
SetupMulticastCaptureFunction · 0.50
TcpServerThreadFunction · 0.50
ServerThreadFunction · 0.50
TYPED_TESTFunction · 0.50
TESTFunction · 0.50

Calls 3

IPv4Function · 0.85
IsSocketIPv4Function · 0.70
assertFunction · 0.50

Tested by 5

SetupMulticastCaptureFunction · 0.40
TcpServerThreadFunction · 0.40
ServerThreadFunction · 0.40
TYPED_TESTFunction · 0.40
TESTFunction · 0.40