Esempio n. 1
0
void SocketAddress::init(const std::string& host, Poco::UInt16 port)
{
	IPAddress ip;
	if (IPAddress::tryParse(host, ip))
	{
		init(ip, port);
	}
	else
	{
		HostEntry he = DNS::hostByName(host);
		HostEntry::AddressList addresses = he.addresses();
		if (addresses.size() > 0)
		{
#if defined(POCO_HAVE_IPv6)
			// if we get both IPv4 and IPv6 addresses, prefer IPv4
			std::sort(addresses.begin(), addresses.end(), AFLT());
#endif
			init(addresses[0], port);
		}
		else throw HostNotFoundException("No address found for host", host);
	}
}
Esempio n. 2
0
File: interf.c Progetto: barak/lush
static at *
Nacces(int arg_number, at **arg_array, int champ)
{
  flt val = Fzero;
  int numero;
  
  ALL_ARGS_EVAL;
  if (arg_number <1 || arg_number >=3)
    ARG_NUMBER(-1);
  numero = AINTEGER(1);
  if (numero<0 || numero>=neurnombre)
    error(NIL,"illegal neuron number",NEW_NUMBER(numero));
  switch(arg_number) {
  case 1:
    val=get_Nfield(numero,champ);
    break;
  case 2:
    val = AFLT(2);
    set_Nfield(numero,champ,val);
    break;
  }
  return NEW_NUMBER(Ftofp(val));
}