Esempio n. 1
0
status_t
BNetworkAddress::SetTo(int family, const char* host, const char* service,
	uint32 flags)
{
	if (family == AF_LINK) {
		if (service != NULL)
			return B_BAD_VALUE;
		return _ParseLinkAddress(host);
			// SetToLinkAddress takes care of setting fStatus
	}

	BReference<const BNetworkAddressResolver> resolver
		= BNetworkAddressResolver::Resolve(family, host, service, flags);
	if (resolver.Get() == NULL)
		return B_NO_MEMORY;
	status_t status = resolver->InitCheck();
	if (status != B_OK)
		return status;

	uint32 cookie = 0;
	status = resolver->GetNextAddress(&cookie, *this);
	if (status != B_OK)
		Unset();
	fHostName = host;
	fStatus = status;
	return status;
}
Esempio n. 2
0
status_t
BNetworkAddress::SetTo(int family, const char* host, uint16 port, uint32 flags)
{
	if (family == AF_LINK) {
		if (port != 0)
			return B_BAD_VALUE;
		return _ParseLinkAddress(host);
	}

	BNetworkAddressResolver resolver;
	status_t status = resolver.SetTo(family, host, port, flags);
	if (status != B_OK)
		return status;

	uint32 cookie = 0;
	return resolver.GetNextAddress(&cookie, *this);
}
Esempio n. 3
0
status_t
BNetworkAddress::SetTo(int family, const char* host, uint16 port, uint32 flags)
{
	if (family == AF_LINK) {
		if (port != 0)
			return B_BAD_VALUE;
		return _ParseLinkAddress(host);
	}

	BReference<const BNetworkAddressResolver> resolver
		= BNetworkAddressResolver::Resolve(family, host, port, flags);
	if (resolver.Get() == NULL)
		return B_NO_MEMORY;
	status_t status = resolver->InitCheck();
	if (status != B_OK)
		return status;

	uint32 cookie = 0;
	return resolver->GetNextAddress(&cookie, *this);
}