📄 gethostname.2
字号:
.\" SCCSID: @(#)gethostname.2 8.1 9/11/90.TH gethostname 2.SH Namegethostname, sethostname \- get or set the name of the current host.SH Syntax.br.B gethostname(\fIname, namelen\fP).br.B char *\fIname\fP;.br.B int \fInamelen\fP;.sp.br.B sethostname(\fIname, namelen\fP).br.B char *\fIname\fP;.br.B int \fInamelen\fP;.SH Description.NXR "gethostname system call".NXR "sethostname system call".NXR "host name" "getting".NXR "host name" "setting"The.PN gethostnamesystem callreturns the standard host name for the current processor, aspreviously set by.PN sethostname. The .I namelenparameter specifies the size of the .I namearray. The returned name is null-terminated unless insufficientspace is provided..PPThe.PN sethostnamesystem callsets the name of the host machine to be.IR name ,which has length.IR namelen .This call is restricted to the superuser andis normally used only when the system is bootstrapped..SH Return Values.IP " 0" 5If the call succeeds, it returns a value of zero..IP \-1If the call fails, a value of \-1 is returned and an error code isplaced in the global location, \fIerrno\fP..SH RestrictionsHost names are limited to 31 characters and may contain only lower case ASCII characters a to z, numbers 0 to 9, dashes (\-), underscores (_), and periods (.)..SH DiagnosticsThe.PN gethostnamesystem call fails under the following condition:.IP [EFAULT] 15The \fIname\fP parameter points outside the process's allocated address space. .PPThe .PN sethostname system call fails under the following conditions:.IP [EPERM] 15The caller is not the superuser..IP [EINVAL]The \fIname\fR or \fInamelen\fR parameter is an invalid address..SH See Alsohostname(1), gethostid(2)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -