gethostid() - Unix,Linux 系統呼叫 - 技術教學
Tutorials Point


  Unix 初學者指南
  Unix Shell 程式設計
  高階 Unix
  Unix 有用參考資料
  Unix 有用資源
  精選閱讀

版權所有 © 2014 tutorialspoint



  首頁     參考資料     討論論壇     關於TP  

gethostid() - Unix,Linux 系統呼叫


previous next AddThis Social Bookmark Button

廣告

名稱

gethostid, sethostid - 獲取或設定當前主機的唯一識別符號

概要

#include <unistd.h>

long gethostid(void);
int sethostid(long hostid);

描述

獲取或設定當前機器的唯一 32 位識別符號。此 32 位識別符號旨在在所有現有的 UNIX 系統中唯一。這通常類似於本地機器的網際網路地址(由 gethostbyname(3) 返回),因此通常不需要設定。

sethostid() 呼叫僅限於超級使用者。

hostid 引數儲存在 /etc/hostid 檔案中。

返回值

gethostid() 返回當前主機的 32 位識別符號,該識別符號由 sethostid(2) 設定。

符合標準

4.2BSD;這些函式在 4.4BSD 中已被刪除。SVr4 包含 gethostid() 但不包含 sethostid()。POSIX.1-2001 指定 gethostid() 但不指定 sethostid()。

檔案

/etc/hostid

示例

id = gethostid ();

/* This is a no-op unless unsigned int is wider than 32 bits. */ id &= 0xffffffff;

參見



previous next Printer Friendly

廣告


  

廣告



廣告