1 客户端连接了服务器的正式IP地址如果错误的话.就会一直的发送连接请求.等待服务器的accept()函数.
如果服务器关闭的话 就必须要在客户端设置一个连接超时,如果指定时间内服务器没有回应则自动关闭.
2 如果用API的话就是gethostbyaddr(),gethostbyname()和inet_addr()函数..
Public Declare Function gethostbyaddr Lib "winsock.dll" (addr As Long, ByVal addr_len As Integer, ByVal addr_type As Integer) As Long
Public Declare Function gethostbyname Lib "winsock.dll" (ByVal host_name As String) As Long
Public Declare Function gethostname Lib "winsock.dll" (ByVal host_name As String, ByVal namelen As Integer) As Integer
Public Declare Function getservbyport Lib "winsock.dll" (ByVal Port As Integer, ByVal proto As String) As Long
Public Declare Function getservbyname Lib "winsock.dll" (ByVal serv_name As String, ByVal proto As String) As Long
Public Declare Function getprotobynumber Lib "winsock.dll" (ByVal proto As Integer) As Long
Public Declare Function getprotobyname Lib "winsock.dll" (ByVal proto_name As String) As Long
基本上就是这些获取IP的方法了吧..别的我就没有了....
至于在WINSOCK控件里面都集成化了,是无法获取服务器IP的....
在服务器端可以用 winsock.localip 来知道服务器的IP地址.
如果在连接的情况下服务器短开连接,WINSOCK控件不知道了..就要定时的去连接一下.预防信息丢失...