日期:2014-05-17  浏览次数:29250 次

用w3Socket替代xmlhttp后的问题,高手Help
因为xmlhttp老是超时假死,serverxmlhttp经常抓不到目标站(如百度这些都有防采集的)。找了好久发现w3Socket这个asp组件,一开始能工作,但后来就经常报错,
Timeout expired while waiting for socket event

代码是这样的。调用函数GetHtml("www.auak.com","/")
JScript code

    Function GetHtml(paraHost,paraFileUrl)
        Dim Socket
        on error resume next 
        Set Socket =Server.CreateObject("Socket.TCP")
        Socket.Host = paraHost & ":80"
        Socket.Timeout =80*1000 '80秒
        If Err.Number <> 0 Then err.Clear
        Socket.open
        Socket.SendLine "GET " & paraFileUrl & " HTTP/1.0"
        Socket.SendLine "HOST: " & paraHost
        Socket.SendLine ""
        Socket.SendLine ""
'        Sleep 200
        Socket.WaitForDisconnect
        If Err.Number <> 0 Then
            GetText = ""
'            response.write Err.Number & " -- " & Err.Description
            Err.Clear
        Else
            GetText = ParseRet(Socket.Buffer, 1)     ' output text from     socket 
        End If
        Socket.Close
        Set Socket = Nothing
    End Function



------解决方案--------------------
这个控件貌似有问题 要不就是asp问题 

使用xmlhttp比较多:
http://www.cnblogs.com/hover/archive/2004/10/09/36212.aspx
------解决方案--------------------
Error while processing Socket opperation: No Data; perhaps no route to host

错误处理的操作:插座没有数据;或者主机不可达