开发者

VB.NET HTTP LAG! Trying to make an IM client on my own

开发者 https://www.devze.com 2022-12-18 11:17 出处:网络
I have recently developed and finished a software in which works like aim. But here\'s the problem, the server worked just fine for local friends because they lived only 25 miles from the server, so i

I have recently developed and finished a software in which works like aim. But here's the problem, the server worked just fine for local friends because they lived only 25 miles from the server, so it was lag-less. But when uploaded to a web host, it lags every time it pings the server. The server is in PHP, so there's no need to buy a dedicated computer for 400$/month more. Here's the function in which the client constantly calls upon:

Public Function GetPage(ByVal url As String)
    Dim WReq As HttpWebRequest
    Dim WResp As WebResponse
    Dim sr As IO.StreamReader

    Try
        WReq = WebRequest.Create(url)
        WReq.CookieContainer = cookies
        WReq.Timeout = "120000"
        WResp = WReq.GetResponse()
        sr = New IO.StreamReader(WResp.GetResponseStream())

        GetPage = sr.ReadToEnd()

        WResp.Close()
        Return (GetPage)
    Catch err As SystemException
        MsgBox("err message: " & err.ToString & vbCrLf)

    Catch ex As Exception
        MsgBox("err message: " & ex.ToString & vbCrLf)

    End Try
End Function

A demo url would be something like http://localhost/chat/newpm.php?to=User&msg=Hello So how does OSCAR do it (the platform for AOL, aka AIM) and how does msg? gtalk or other big im clients do it?

I 开发者_StackOverflow社区was thinking about recoding the getpage function so that it would connect to a TCP server and constantly wait for new messages which I am still not sure if this might cause a lag if the host is in the US and the client is not(for example). Could you please provide me a remedy to this problem?


The Timeout is really high. Check if the app closes the connection after receive the response stream. How many aconnections the computer accepts otherwise the connectios will lock the request until one goes free.


Ok to answer John Feminella: Exactly I agreee, how does AIM MSN and others solve this hang issue? Dbasnett: return(GetPage) will return the result of the requested page, and this is just the main snipppet of the code which is called every second at least two times. John Saunders: I don't understand the purpose or function of the "using" blocks, I added the catch so that the user is not notified when the server times out or can't be resolved. Sein Kraft: Time out is only 2 minutes, i don't think it does GetPage(Login.server & "pms.php?to=" & to) That's all, then it would parse the results from the response.

0

精彩评论

暂无评论...
验证码 换一张
取 消