Computer Science Canada

Better OpenURLConnection

Author:  ecliptical [ Wed Jan 04, 2006 1:46 pm ]
Post subject:  Better OpenURLConnection

The Net.OpentConnection probably works like this to some degree but I find having control over the HTTP command may give you some more power...anyway this is part of the Online Multiplayer modules i'm making

code:

module gameServer
    export OpenURLConnection
    procedure OpenURLConnection (httpCommand, url : string)
        var line : string (1)
        var netStream : int
        netStream := Net.OpenConnection (url, 80)
        if netStream <= 0 then
            put "Unable to connect to ", url
            return
        end if
        if httpCommand="GET" then
        var HEADER : string := "GET /index.html" %HTTP/1.1+ chr (10) + "Host: www..ca"
        %var sendHEADER : string := HEADER + chr (10) + "Accept-Ranges: bytes" + chr (10) + "Connection: close" + chr (10) + chr (10)
        put HEADER
        put : netStream, HEADER
        end if
        loop
            get : netStream, line : 1
            put line ..
        end loop
        Net.CloseConnection (netStream)
    end OpenURLConnection
end gameServer
put "Working"
gameServer.OpenURLConnection ("GET","www.yahoo.com")





[/code]

Author:  Taur [ Wed Jan 04, 2006 5:17 pm ]
Post subject: 

Very Happy so are you gonna show us how to submit info and read it in the site too?

Author:  ecliptical [ Wed Jan 04, 2006 5:52 pm ]
Post subject: 

check the tutorial section it's there.


: