C语言函数 概述: 返回对应于给定地址的主机信息. #include <winsock.h> struct hostent FAR *PASCAL FAR gethostbyaddr(const char FAR * addr, int len, int type); addr:指向网络字节顺序地址的指针. len: 地址的长度,在AF_INET类型地址中为4. type:地址类型,应为AF_INET. 注释: gethostbyaddr()返回对应于给定地址的包含主机名字和地址信息的host…
网络编程里经常需要获得主机的相关信息,下面围绕相关的函数以及用到的结构来说明. 获得主机名:int gethostname( char FAR *name, //[out] Pointer to a buffer that receives the local host name. int namelen //[in] Length of the buffer. );返回0表示成功,失败返回SOCKET_ERROR,错误代码通过调用WSAGetLastError查看 根据主机名获得主机信息:st…