Readline Internet Code Problem
BlitzMax Forums/BlitzMax Programming/Readline Internet Code Problem
| ||
I've been making a sample code for a blitzmax example, just by reusing my old functions from others programs that always are and worked fine.SuperStrict Function request:TStream(location$,host$) Local http:TSocket = CreateTCPSocket () Local www:TStream=CreateSocketStream(http) If ConnectSocket (http, HostIp (host), 80) WriteLine www, "GET "+location+" HTTP/1.1" WriteLine www, "Host: " + host WriteLine www, "User-Agent: BlitzMax" WriteLine www, "Accept: */*" WriteLine www, "Keep-Alive: 300" WriteLine www, "Connection: keep-alive" WriteLine www, "" Else Return Null EndIf Return www End Function Function stream_to_string:String(stream:TStream) Local result:String="" If stream While Not (Eof(stream)) Local line:String = ReadLine(stream) DebugLog line result=result+line+Chr(10)+Chr(13) Wend Else Return "Error reading page!" EndIf Return result End Function Global blitzwin:TGadget = CreateWindow ("Internet",10,10,640,480) Global textfield:TGadget = CreateTextArea(4,4,400,400,blitzwin) Global host:TGadget = CreateTextField(410,4,200,22,blitzwin) Global location:TGadget = CreateTextField(410,40,200,22,blitzwin) Global valider:TGadget = CreateButton ("obtenir",410,80,100,22,blitzwin) SetGadgetText( host,"www.google.fr" ) SetGadgetText( location,"/index.html" ) While WaitEvent() Select EventID() Case EVENT_GADGETACTION Select EventSource() Case valider Local i:TStream = request(TextFieldText(location),TextFieldText(host)) Local s:String = stream_to_string(i) SetGadgetText( textfield , s ) End Select Case EVENT_WINDOWCLOSE End End Select Wend End The execution freezes at Readline, Itself occuring at the end of the file (and as such after successfully reading the internet page), I've been trying to find what is wrong for hours but my head is about to explode now! :O Anyone can help me please? |