ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/shostn.htm

274 lines
6.6 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<title>sethostname()--Set Host Name</title>
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- Begin Header Records ========================================== -->
<!-- Unix8 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
<!--End Header Records -->
<!-- Edited by Kersten Feb 02 -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<a name="Top_Of_Page"></a>
<!-- Java sync-link -->
<script type="text/javascript" language="Javascript" src="../rzahg/synch.js">
</script>
<h2>sethostname()--Set Host Name</h2>
<div class="box" style="width: 60%;">
<br>
&nbsp;&nbsp;Syntax<br>
<pre>
#include &lt;sys/types.h&gt;
#include &lt;sys/socket.h&gt;
int sethostname(char *<em>name</em>,
int <em>length</em>)
</pre>
<br>
&nbsp;&nbsp;Service Program Name: QSOSRV1<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Yes<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <em>sethostname()</em> function is used to set the name of the host for
a system.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong>name</strong></dt>
<dd>(Input) The pointer to a character array where the host name is stored.<br>
<br>
</dd>
<dt><strong>length</strong></dt>
<dd>(Input) The length of the <em>name</em> parameter.</dd>
</dl>
<br>
<h3>Authorities</h3>
<p>No authorization is required.</p>
<br>
<h3>Return Value</h3>
<p><em>sethostname()</em> returns an integer. Possible values are:</p>
<ul>
<li>-1 (unsuccessful)<br>
<br>
</li>
<li>0 (successful)</li>
</ul>
<br>
<h3>Error Conditions</h3>
<p>When <em>sethostname()</em> fails, <em>errno</em> can be set to one of the
following:</p>
<table cellpadding="5">
<!-- cols="15 85" -->
<tr>
<td align="left" valign="top"><em>[EFAULT]</em></td>
<td align="left" valign="top">Bad address.
<p>The system detected an address which was not valid while attempting to
access the <em>name</em> parameter.</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EINVAL]</em></td>
<td align="left" valign="top">Parameter not valid.
<p>This error code indicates one of the following:</p>
<ul>
<li>The <em>length</em> parameter specifies a negative value or a value that is
greater than the allowed maximum length.<br>
<br>
</li>
<li>The host name pointed to by the <em>name</em> parameter contains characters
that are not invariant.</li>
</ul>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EPERM]</em></td>
<td align="left" valign="top">Operation not permitted.
<p>The process does not have the appropriate privileges to use
<em>sethostname()</em>.</p>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EIO]</em></td>
<td align="left" valign="top">Input/output error.<br>
<br>
</td>
</tr>
<tr>
<td align="left" valign="top"><em>[EUNKNOWN]</em></td>
<td align="left" valign="top">Unknown system state.</td>
</tr>
</table>
<br>
<br>
<h3>Error Messages</h3>
<table width="100%" cellpadding="5">
<!-- cols="15 85" -->
<tr>
<th align="left" valign="top">Message ID</th>
<th align="left" valign="top">Error Message Text</th>
</tr>
<tr>
<td width="15%" valign="top">CPE3418 E</td>
<td width="85%" valign="top">Possible APAR condition or hardware failure.</td>
</tr>
<tr>
<td align="left" valign="top">CPF9872 E</td>
<td align="left" valign="top">Program or service program &amp;1 in library
&amp;2 ended. Reason code &amp;3.</td>
</tr>
<tr>
<td align="left" valign="top">CPFA081 E</td>
<td align="left" valign="top">Unable to set return value or error code.</td>
</tr>
</table>
<br>
<br>
<h3>Usage Notes</h3>
<ol>
<li>A process must have the <samp>*iosyscfg</samp> special authority to use the
<em>sethostname()</em>.<br>
<br>
</li>
<li>Maximum length of host names is defined by [MAXHOSTNAMELEN] (defined in
<strong>&lt;sys/param.h&gt;</strong>).<br>
<br>
</li>
<li>The host name can be set in the following two ways (and users should be
aware of the implications of the way they choose):
<ul>
<li>By using option 12 (Change local domain and host names) on the Configure
TCP/IP (CFGTCP) menu. When option 12 is used to change the local domain name or
local host name, the system appends the local domain name to the local host
name and stores the value for access by <em>sethostname()</em> and
<em>gethostname()</em>.<br>
<br>
</li>
<li>By using the <em>sethostname()</em> function. When <em>sethostname()</em>
is used to set the host name, the TCP/IP configuration file is not affected.
Only the field that is accessed by <em>sethostname()</em> and
<em>gethostname()</em> is changed.</li>
</ul>
<br>
</li>
<li>The name of the host is set to NULL when the pointer to the host name
(pointed to by the <em>name</em> parameter) is set to NULL.<br>
<br>
</li>
<li>The host name is assumed to be in the default coded character set
identifier (CCSID) currently in effect for the job. In addition, the host name
must adhere to the following conventions.
<ul>
<li>The first character must be either an English alphabetic character or a
numeric character.<br>
<br>
</li>
<li>The last character must be either an English alphabetic character, a
numeric character, or a period (.).<br>
<br>
</li>
<li>Blanks are not allowed (trailing blanks are removed).<br>
<br>
</li>
<li>The special characters period(.), underscore(_), and minus(-) are
allowed.<br>
<br>
</li>
<li>Parts of the name separated by periods (.) cannot exceed 63 characters in
length.
<p><strong>Note:</strong> Each part of the name separated by periods must begin
and end with an English alphanumeric character.</p>
</li>
<li>Internet address names (in the form nnn.nnn.nnn.nnn (where nnn is a decimal
number)) are not allowed.<br>
<br>
</li>
<li>Names must be from 1 to 255 characters in length.</li>
</ul>
</li>
</ol>
<br>
<h3>Related Information</h3>
<p><a href="ghostn.htm">gethostname()</a>--Retrieve Host Name</p>
<br>
<hr>
API introduced: V3R1
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> |
<a href="unix.htm">UNIX-Type APIs</a> |
<a href="aplist.htm">APIs by category</a> </td>
</tr>
</table>
</center>
</body>
</html>