haiku/headers/os/net/NetworkAddressResolver.h
Axel Dörfler 836c43f2b8 * Factored out a BNetworkAddressResolver from BNetworkAddress, that also allows
to iterate over all possible addresses, as suggested privately by Rene.
* Added flags to the resolving methods that allow more control over the
  addresses returned.
* Added setters to BNetworkAddress that accept a service name instead of port
  number, renamed PortName() to ServiceName().
* Made the sockaddr* cast operators return a const sockaddr as it was supposed
  to be, although I should probably add non-const ones as well.
* This also simplified the code somewhat.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38039 a95241bf-73f2-0310-859d-f6bbb57e9c96
2010-08-12 11:27:14 +00:00

63 lines
1.6 KiB
C++

/*
* Copyright 2010, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _NETWORK_ADDRESS_RESOLVER_H
#define _NETWORK_ADDRESS_RESOLVER_H
#include <SupportDefs.h>
class BNetworkAddress;
struct addrinfo;
// flags for name resolution
enum {
B_NO_ADDRESS_RESOLUTION = 0x0001,
B_UNCONFIGURED_ADDRESS_FAMILIES = 0x0002,
};
class BNetworkAddressResolver {
public:
BNetworkAddressResolver();
BNetworkAddressResolver(const char* address,
uint16 port = 0, uint32 flags = 0);
BNetworkAddressResolver(const char* address,
const char* service, uint32 flags = 0);
BNetworkAddressResolver(int family,
const char* address, uint16 port = 0,
uint32 flags = 0);
BNetworkAddressResolver(int family,
const char* address, const char* service,
uint32 flags = 0);
~BNetworkAddressResolver();
status_t InitCheck() const;
void Unset();
status_t SetTo(const char* address, uint16 port = 0,
uint32 flags = 0);
status_t SetTo(const char* address, const char* service,
uint32 flags = 0);
status_t SetTo(int family, const char* address,
uint16 port = 0, uint32 flags = 0);
status_t SetTo(int family, const char* address,
const char* service, uint32 flags = 0);
status_t GetNextAddress(uint32* cookie,
BNetworkAddress& address) const;
status_t GetNextAddress(int family, uint32* cookie,
BNetworkAddress& address) const;
private:
addrinfo* fInfo;
status_t fStatus;
};
#endif // _NETWORK_ADDRESS_RESOLVER_H