Esempio n. 1
0
//convert a hostname to an ip address
int GroveStreams::dnsLookup(const char* hostname, IPAddress& addr)
{
    int ret = 0;
    DNSClient dns;

    dns.begin(Ethernet.dnsServerIP());
    ret = dns.getHostByName(hostname, addr);
    return ret;
}
int EthernetClient::connect(const char* host, uint16_t port) {
  // Look up the host first
  int ret = 0;
  DNSClient dns;
  IPAddress remote_addr;

  dns.begin(Ethernet.dnsServerIP());
  ret = dns.getHostByName(host, remote_addr);
  if (ret == 1) {
    return connect(remote_addr, port);
  } else {
    return ret;
  }
}
int EthernetClient::connect(const char* host, uint16_t port)
{
	int ret = 0;
	DNSClient dns;
	IPAddress remote_addr;
	IPAddress dns_server;

	dns.begin(Ethernet.dnsServerIP());
	ret = dns.getHostByName(host, remote_addr);
	if (ret == 1)
		return connect(remote_addr, port);
	
	return ret;
}
Esempio n. 4
0
HttpClient::HttpClient(Client& aClient, const char* aProxy, uint16_t aProxyPort)
 : iClient(&aClient), iProxyPort(aProxyPort)
{
  resetState();
  if (aProxy)
  {
    // Resolve the IP address for the proxy
    DNSClient dns;
    dns.begin(Ethernet.dnsServerIP());
    // Not ideal that we discard any errors here, but not a lot we can do in the ctor
    // and we'll get a connect error later anyway
    (void)dns.getHostByName(aProxy, iProxyAddress);
  }
}
Esempio n. 5
0
int EthernetUDP::beginPacket(const char *host, uint16_t port)
{
	// Look up the host first
	int ret = 0;
	DNSClient dns;
	IPAddress remote_addr;

	dns.begin(Ethernet.dnsServerIP());
	ret = dns.getHostByName(host, remote_addr);
	if (ret == 1)
		return beginPacket(remote_addr, port);
	else
		return ret;
}
int EthernetClient::connect(const char * host, uint16_t port)
{
	DNSClient dns; // Look up the host first
	IPAddress remote_addr;

	if (sockindex < MAX_SOCK_NUM) {
		if (Ethernet.socketStatus(sockindex) != SnSR::CLOSED) {
			Ethernet.socketDisconnect(sockindex); // TODO: should we call stop()?
		}
		sockindex = MAX_SOCK_NUM;
	}
	dns.begin(Ethernet.dnsServerIP());
	if (!dns.getHostByName(host, remote_addr)) return 0; // TODO: use _timeout
	return connect(remote_addr, port);
}
Esempio n. 7
0
/**
 * @brief
 * @note
 * @param
 * @retval
 */
int UIPClient::connect(const char* host, uint16_t port) {

    // Look up the host first
    int         ret = 0;
#if UIP_UDP
    DNSClient   dns;
    IPAddress   remote_addr;

    dns.begin(UIPEthernetClass::_dnsServerAddress);
    ret = dns.getHostByName(host, remote_addr);
    if(ret == 1) {
        return connect(remote_addr, port);
    }
#endif
    return ret;
}
Esempio n. 8
0
//int main(int argc, char** argv)
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
	DNSClient c;
	return c.main();
}