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() 返回由sethostid(2)設定的當前主機的32位識別符號。

符合標準

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

廣告


  

廣告



廣告