| 20 | #include "Internal/SocketServer.inl" |
| 21 | |
| 22 | SC::ResultSocket SC::SocketDescriptor::getAddressFamily(SocketFlags::AddressFamily& addressFamily) const |
| 23 | { |
| 24 | SocketAddress socketInfo; |
| 25 | |
| 26 | socklen_t socketInfoLen = sizeof(socketInfo.handle); |
| 27 | if (::getsockname(handle, &socketInfo.handle.reinterpret_as<struct sockaddr>(), &socketInfoLen) == SOCKET_ERROR) |
| 28 | { |
| 29 | #if SC_PLATFORM_WINDOWS |
| 30 | const uint32_t nativeError = static_cast<uint32_t>(WSAGetLastError()); |
| 31 | #else |
| 32 | const uint32_t nativeError = static_cast<uint32_t>(errno); |
| 33 | #endif |
| 34 | return ResultSocket::withNativeError(SocketError::DescriptorQueryFailed, SocketErrorDetail::GetSocketAddress, |
| 35 | nativeError); |
| 36 | } |