setnetent STAYOPEN |
由於getintent()檢索的信息在網絡數據庫中的下一行,然後setnetent集(或重置)枚舉的主機項的設置開始。這個函數應該被調用之前第一次調用getnetent。STAYOPEN參數是可選的,在大多數係統上未使用過的。
Nothing
試試下麵的例子:
#!/usr/bin/perl
#by www.gitbook.net
use Socket;
while ( ($name, $aliases, $addrtype, $net) = getnetent() ){
print "Name = $name\n";
print "Aliases = $aliases\n";
print "Addrtype = $addrtype\n";
print "Net = $net\n";
}
setnetent(1); # Rewind the database;
while ( ($name, $aliases, $addrtype, $net) = getnetent() ){
print "Name = $name\n";
print "Aliases = $aliases\n";
print "Addrtype = $addrtype\n";
print "Net = $net\n";
}
endnetent(); # Closes the database;