[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Communications Technical Reference, Volume 2

getdomainname Subroutine


Gets the name of the current domain.


Standard C Library (libc.a)


int getdomainname (Name, Namelen)
char *Name;
int Namelen;


The getdomainname subroutine returns the name of the domain for the current processor as previously set by the setdomainname subroutine. The returned name is null-terminated unless insufficient space is provided.

The purpose of domains is to enable two distinct networks that may have host names in common to merge. Each network would be distinguished by having a different domain name. Only the Network Information Service (NIS) and the sendmail command make use of domains.

Note: Domain names are restricted to 64 characters.


Name Specifies the domain name to be returned.
Namelen Specifies the size of the array pointed to by the Name parameter.

Return Values

If the call succeeds, a value of 0 is returned. If the call is unsuccessful, a value of -1 is returned and an error code is placed in the errno global variable.

Error Codes

The following error may be returned by this subroutine:

EFAULT The Name parameter gave an invalid address.

Implementation Specifics

The getdomainname subroutine is part of Base Operating System (BOS) Runtime.

All applications containing the getdomainname subroutine must be compiled with _BSD set to a specific value. Acceptable values are 43 and 44. In addition, all socket applications must include the BSD libbsd.a library.

Related Information

The gethostname subroutine, setdomainname subroutine, sethostname subroutine.

Sockets Overview in AIX Version 4.3 Communications Programming Concepts.

[ Previous | Next | Contents | Glossary | Home | Search ]