Changeset View
Changeset View
Standalone View
Standalone View
source/Host/common/SocketAddress.cpp
Show All 22 Lines | |||||
#if !defined(_WIN32) | #if !defined(_WIN32) | ||||
#include <arpa/inet.h> | #include <arpa/inet.h> | ||||
#endif | #endif | ||||
#include <assert.h> | #include <assert.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include "lldb/Host/PosixApi.h" | #include "lldb/Host/PosixApi.h" | ||||
#include "lldb/Utility/Status.h" | |||||
// WindowsXP needs an inet_ntop implementation | // WindowsXP needs an inet_ntop implementation | ||||
#ifdef _WIN32 | #ifdef _WIN32 | ||||
#ifndef INET6_ADDRSTRLEN // might not be defined in older Windows SDKs | #ifndef INET6_ADDRSTRLEN // might not be defined in older Windows SDKs | ||||
#define INET6_ADDRSTRLEN 46 | #define INET6_ADDRSTRLEN 46 | ||||
#endif | #endif | ||||
▲ Show 20 Lines • Show All 211 Lines • ▼ Show 20 Lines | SocketAddress::GetAddressInfo(const char *hostname, const char *servname, | ||||
struct addrinfo *service_info_list = NULL; | struct addrinfo *service_info_list = NULL; | ||||
int err = ::getaddrinfo(hostname, servname, &hints, &service_info_list); | int err = ::getaddrinfo(hostname, servname, &hints, &service_info_list); | ||||
if (err == 0 && service_info_list) { | if (err == 0 && service_info_list) { | ||||
for (struct addrinfo *service_ptr = service_info_list; service_ptr != NULL; | for (struct addrinfo *service_ptr = service_info_list; service_ptr != NULL; | ||||
service_ptr = service_ptr->ai_next) { | service_ptr = service_ptr->ai_next) { | ||||
addr_list.emplace_back(SocketAddress(service_ptr)); | addr_list.emplace_back(SocketAddress(service_ptr)); | ||||
} | } | ||||
} else if (err) { | |||||
// Consume the error here. | |||||
Status error; | |||||
#ifdef _WIN32 | |||||
error.SetError(err, lldb::eErrorTypeWin32); | |||||
#else | |||||
error.SetError(err, lldb::eErrorTypePOSIX); | |||||
#endif | |||||
zturner: Perhaps we could define something like `lldb::eErrorTypeHostNative` to avoid this ifdef. | |||||
printf("SocketAddress::GetAddressInfo - %s\n", error.AsCString()); | |||||
Not Done ReplyInline ActionsWriting to stdout like this is very rude. If there isn't a suitable way to return this info, then I suggest writing this to the log instead. labath: Writing to stdout like this is very rude. If there isn't a suitable way to return this info… | |||||
Not Done ReplyInline ActionsThis comment still stands. labath: This comment still stands. | |||||
} | } | ||||
if (service_info_list) | if (service_info_list) | ||||
::freeaddrinfo(service_info_list); | ::freeaddrinfo(service_info_list); | ||||
return addr_list; | return addr_list; | ||||
} | } | ||||
bool SocketAddress::SetToLocalhost(sa_family_t family, uint16_t port) { | bool SocketAddress::SetToLocalhost(sa_family_t family, uint16_t port) { | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |
Perhaps we could define something like lldb::eErrorTypeHostNative to avoid this ifdef.