址指针r
str保存地址的指针r
size:str的大小。r
i
ti
et_pto
i
tdamai
charsrcvoidaddrr
功能:把一个字符串转化为二进制r
返回值:成功返回0错误返回1;r
r
6、地址的查询r
主要分:系统信息、主机、网络、协议、服务r
(1)主机的系统信息r
i
cludesysuts
amehr
i
ttu
amestructuts
amebufr
功能:获取系统信息r
返回值:成功0失败1r
参数r
structuts
amer
charsys
ame操作系统r
char
ode
amet网络上的主机名r
charreleasett操作系统的发布版本号r
charversio
tt操作系统版本号r
charmachi
ett硬件信息r
r
r
(2)主机信息(etchosts)r
i
clude
etdbhr
i
cludesyssockethtttttttr
structhoste
tgethostbyaddrco
stvoidaddri
tle
i
ttyper
voidsethoste
ti
tstayope
r
功能:打开数据文件,并设置是否保留打开r
参数:r
1:保持打开TCPr
0:每次关闭UDPr
voide
dhoste
tvoidr
功能:关闭数据文件r
structhoste
tgethoste
tvoidr
功能:每次获取一个hoste
tj结构体r
structhoste
tr
charh_
ameofficial
ameofhostr
charh_aliasesaliaslistr
i
th_addrtypehostaddresstyper
i
th_le
gthle
gthofaddressr
charh_addr_listlistofaddressesr
r
3获取网络名(etcserivce)r
struct
ete
tget
ete
tvoidr
struct
ete
tget
etby
ameco
stchar
amer
struct
ete
tget
etbyaddrlo
g
eti
ttyper
voidset
ete
ti
tstayope
r
voide
d
ete
tvoidr
struct
ete
tr
char
_
ameofficial
etwork
amer
char
_aliasesaliaslistr
i
t
_addrtype
etaddresstyper
u
sig
edlo
gi
t
_
et
etwork
umberr
r
4获取协议名和协议号(etcprotocols)r
structprotoe
tgetprotoe
tvoidr
structprotoe
tgetprotoby
ameco
stchar
amer
structprotoe
tgetprotoby
umberi
tprotor
voidsetprotoe
ti
tstayope
r
voide
dprotoe
tvoidr
structprotoe
tr
charp_
ameofficialprotocol
amer
charp_aliasesaliaslistr
i
tp_protoprotocol
r