deps/PicklingTools170Release/M2k/udpif/udpsockets.cc
int_4 UDPSocketLib::UDP_findHostByName (const char *hostname,
      char *h_name_p,
      int_4 h_name_l,
      struct sockaddr_in* sap)
{
  struct hostent * hp;
  
  /* For those of you using purify, gethostbyname seems to use up a 
   * socket on solaris (probably to talk to the dns server).  This
   * is not a problem. */
  hp = gethostbyname(hostname);

  if (0 == hp) {
    return -1;
  }

  if (0 != h_name_p) {
    strncpy(h_name_p, hp->h_name, h_name_l);
    h_name_p[h_name_l-1] = 0;	/* Force EOS termination */
  }
  if (0 != sap) {
    sap->sin_family = hp->h_addrtype;
    memcpy(&sap->sin_addr, hp->h_addr_list[0], hp->h_length);
  }

  return 0;
}
/* UDP_findHostByName

Description:
  A wrapper to get the commonly desired values out of gethostbyname,
  which generally is not thread safe, in a thread-safe manner where
  supported by a given host.

Arguments:
  hostname (IN) -- ASCIIZ name of host to look up
  h_name_p (OUT) -- canonical name of host
  h_name_l (IN) -- maximum number of chars to store for host name, incl EOS
  sap (OUT) -- pointer to a sockaddr_in buffer to hold address/family info

Returns:
  Zero if all went well; -1 if there was an error.

NOTES:
  + The user is responsible for making sure the output buffers are large
    enough
  + If the reference pointers are NULL, the corresponding outputs are
    not set.
*/
UDP_findHostByName
Description:
A wrapper to get the commonly desired values out of gethostbyname,
which generally is not thread safe, in a thread-safe manner where
supported by a given host.



Zero if all went well; -1 if there was an error.

+ The user is responsible for making sure the output buffers are large
enough
+ If the reference pointers are NULL, the corresponding outputs are
not set.
UDP_findHostByName Description : A wrapper to get the commonly desired values out of gethostbyname which generally is not thread safe in a thread - safe manner where supported by a given host . Zero if all went well ; - 1 if there was an error . + The user is responsible for making sure the output buffers are large enough + If the reference pointers are NULL the corresponding outputs are not set .
int_4 UDPSocketLib::UDP_findHostByName (const char *hostname,
      char *h_name_p,
      int_4 h_name_l,
      struct sockaddr_in* sap)
{
  struct hostent * hp;
  hp = gethostbyname(hostname);
  if (0 == hp) {
    return -1;
  }
  if (0 != h_name_p) {
    strncpy(h_name_p, hp->h_name, h_name_l);
    h_name_p[h_name_l-1] = 0;	
  }
  if (0 != sap) {
    sap->sin_family = hp->h_addrtype;
    memcpy(&sap->sin_addr, hp->h_addr_list[0], hp->h_length);
  }
  return 0;
}
int_4 UDPSocketLib :: UDP_findHostByName ( const char * hostname , char * h_name_p , int_4 h_name_l , struct sockaddr_in * sap ) { struct hostent * hp ; hp = gethostbyname ( hostname ) ; if ( 0 == hp ) { return -1 ; } if ( 0 != h_name_p ) { strncpy ( h_name_p , hp -> h_name , h_name_l ) ; h_name_p [ h_name_l - 1 ] = 0 ; } if ( 0 != sap ) { sap -> sin_family = hp -> h_addrtype ; memcpy ( & sap -> sin_addr , hp -> h_addr_list [ 0 ] , hp -> h_length ) ; } return 0 ; }
UDP_findHostByName
Description:
A wrapper to get the commonly desired values out of gethostbyname,
which generally is not thread safe, in a thread-safe manner where
supported by a given host.
UDP_findHostByName Description : A wrapper to get the commonly desired values out of gethostbyname which generally is not thread safe in a thread - safe manner where supported by a given host .
/* For those of you using purify, gethostbyname seems to use up a 
   * socket on solaris (probably to talk to the dns server).  This
   * is not a problem. */ /* Force EOS termination */