客户端如何用域名访问服务端

解决方案 »

  1.   

    To zhaolaoxin 感谢回答问题。
    我以前是这样,将服务器的IP写在客户端保存,用在局域网,Socket联接,定义了一个端口。现在准备用在广域网,可以直接把域名写在原来IP的文本框中就可以了吗?
      

  2.   

    gethostbyname
    The gethostbyname function retrieves host information corresponding to a host name from a host database.Note  The gethostbyname function has been deprecated by the introduction of the getaddrinfo function. Developers creating Windows Sockets 2 applications are urged to use the getaddrinfo function instead of gethostbyname.
    struct hostent* FAR gethostbyname(
      const char* name
    );Parameters
    name 
    [in] Pointer to the null-terminated name of the host to resolve.