Problem with http GET command...
Posted: Mon Mar 12, 2007 9:14 pm
Hi,
I'm new in PureBasic programming, and I have problem with using http command get. I'm trying in simple way to download a small file - logo of PB of this forum, and I dont recieve the information from server.
This is my code:
I'm new in PureBasic programming, and I have problem with using http command get. I'm trying in simple way to download a small file - logo of PB of this forum, and I dont recieve the information from server.
This is my code:
Code: Select all
Global EOL$
EOL$ = Chr(13)+Chr(10)
tekst.s
con.l
wynik.l
*bufor=AllocateMemory(1024)
bufor_len.l
otrzymano_len.l
polecenie.s ;tresc polecenia
polecenieb.b ;czy bylo polecenie
czs.s
OpenConsole()
InitNetwork()
ConsoleTitle("Klient")
con=OpenNetworkConnection("www.purebasic.fr",80,#PB_Network_TCP)
If con<>NULL
PrintN("connected")
EndIf
PrintN("prosba o plik")
czs="GET /english/templates/subSilver/images/logo_phpBB.gif HTTP/1.0" + eol$
czl=Len(czs)
PokeS(*bufor,czs,czl,#PB_Ascii)
wynik=SendNetworkData(con,*bufor,czl)
PrintN("wsend: " + Str(wynik))
Repeat
Delay(100)
wynik=NetworkClientEvent(con)
Select wynik
Case #PB_NetworkEvent_Data
PrintN("recieving...")
otrzymano_len=1024
*bufor=AllocateMemory(1024)
;otrzymywanie
wynik=ReceiveNetworkData(con,*bufor,otrzymano_len)
If wynik>1
tekst=PeekS(*bufor,wynik)
PrintN("recieved: " + tekst)
;
EndIf
EndSelect
polecenieb=0
tekst=""
key$=Inkey()
If key$<>""
Print("to exit/quit write 'end': ")
tekst=Input()
EndIf
Until (tekst="end")
CloseNetworkConnection(con)
CloseConsole()
End