![]() |
Macintosh Development |
[Home]
[About Us]
[People]
[Information Systems]
[Kerberos for Macintosh]
[Applications]
[Miscellaneous Documentation]
![]() |
DNS and Service Functions |
struct hostent * gethostbyname (const char *hostname);Given the hostname in
hostname,gethostbyname()uses DNS to return astruct hostentstructure. Note that this operation may block and should be cancelled using AbortAllDNSOperations().Note that you should copy out the contents of this structure since it is internal to the library.
struct hostent * gethostbyaddr (const void *addr, size_t len, int family);Given the IP address in
addr,gethostbyaddr()uses DNS to return ahostentstructure. Note thataddris astruct sockaddr_in *.Note that you should copy out the contents of the returned structure since it is internal to the library.
int gethostname (char *name, size_t namelen);Gets the local hostname and puts it in the buffer
name, truncated tonamelen.namelenshould be the size of the buffer.Returns 0 on success, -1 on error. If you get an error, call
GetMITLibError()to find out the error code.struct hostent * gethostaddr ();gethostaddr()uses DNS to return astruct hostentstructure for the local host. In a configuration such as NAT where DNS servers fail to answer for the local IP address, only the h_addr array of the returned structure is filled out and the hostname is left as an empty string. Note that this operation may block and should be cancelled using AbortAllDNSOperations().Note that you should copy out the contents of the returned structure since it is internal to the library.
struct servent * getservent (void);
getservent()reads the next entry of the services database in Internet Config. The services database in IC is the equivalent of /etc/services on Unix machines.A connection to Internet Config is opened, if necessary.
void endservent (void);Closes the connection to Internet Config.
struct servent * getservbyname (const char *servname, const char *protname);
getservbyname()searches the services database in Internet Config from the beginning and finds the first entry for which the service name specified byservnamematches thes_namemember and the protocol name specified byprotnamematches thes_protomember. Ifprotonameis NULL, any value of thes_protomember will be matched.A connection to Internet Config is opened, if necessary.
struct servent * getservbyport (int port, const char *protname);
getservbyport()function searches the InternetConfig services database from the beginning and finds the first entry for which the port specified byportmatches thes_portmember and the protocol name specified byprotnamematches the s_proto member. Ifprotnameis NULL, any value of thes_protomember will be matched. Theportargument must be in network byte order.A connection to Internet Config is opened, if necessary.
Questions or comments? Send mail to macdev@mit.edu
Last updated on $Date: 2003/11/19 20:49:22 $
Last modified by $Author: smcguire $