MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / ipAddress

Function ipAddress

source/kernel/knativesocket.cpp:1667–1690  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1665}
1666
1667U32 ipAddress() {
1668 char hostbuffer[256];
1669 struct hostent* host_entry;
1670 int hostname;
1671 struct in_addr* addr_list;
1672
1673 // retrieve hostname
1674 hostname = gethostname(hostbuffer, sizeof(hostbuffer));
1675 if (hostname == -1) {
1676 return 0;
1677 }
1678
1679 // Retrieve IP addresses
1680 host_entry = gethostbyname(hostbuffer);
1681 if (host_entry == NULL) {
1682 return 0;
1683 }
1684 addr_list = *(struct in_addr**)host_entry->h_addr_list;
1685#ifdef WIN32
1686 return addr_list->S_un.S_addr;
1687#else
1688 return addr_list->s_addr;
1689#endif
1690}

Callers 1

sendtoMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected