socket conection via proxy ?
BlitzMax Forums/BlitzMax Programming/socket conection via proxy ?
| ||
Topic says socket but i meant stream. I'm creating a stream to parse a web page. which works well, and I would like to run this stream through a proxy, has anyone done this before, anyone got any ideas how I would go about it in MAX. |
| ||
A HTTP proxy is simple: You connect to a proxy server and define the host attribute in the http request. Like: Connect to 123.123.123.123 and send the following request: Host: google.com HTTP/1.0 User-Agent: XYZ Accept: application/xhtml+xml,text/html Connection: close cu olli |
| ||
Example? You can start with this:Local stream:TStream Local proxyserver:String="http::114.30.47.10" Local url:String="www.blitzmax.com" Local port:Int=80 stream=OpenStream(proxyserver) WriteLine(stream, "CONNECT " + url + ":" + port + " HTTP/1.1") WriteLine(stream, "User-Agent: MultiProx") WriteLine(stream, "") While Not stream.Eof() Print stream.ReadLine() Wend End |
| ||
This is working for me:Local stream:TStream Local proxyserver:String="217.198.113.35" Local URL:String="http://www.blitzbasic.com" Local port:Int = 3128 stream=CreateProxyStream(proxyserver,port) WriteLine stream, "GET " + URL + " HTTP/1.1" WriteLine stream, "User-Agent: MultiProx" WriteLine stream, "Connection: Close" WriteLine stream, "" While Not stream.Eof() Print stream.ReadLine() Wend End Function CreateProxyStream:TStream(host:String , port:Int) Local sock:TSocket = CreateTCPSocket() ConnectSocket(sock,HostIp(host),port) Return CreateSocketStream(sock , True) End Function |