HTTPRequest return order

Just starting out? Need help? Post your questions and find answers here.
karu
Posts: 40
Joined: Mon Feb 24, 2014 10:16 pm

HTTPRequest return order

Post by karu »

I make requests:

HTTPRequest(#PB_HTTP_Get, "http://127.0.0.1/query.php?nr=1", @HttpGetEvent())
HTTPRequest(#PB_HTTP_Get, "http://127.0.0.1/query.php?nr=2", @HttpGetEvent())
HTTPRequest(#PB_HTTP_Get, "http://127.0.0.1/query.php?nr=3", @HttpGetEvent())
HTTPRequest(#PB_HTTP_Get, "http://127.0.0.1/query.php?nr=4", @HttpGetEvent())

depends server load, files may come in other order, example:
3
1
2
4

If i make several queries in succession, the files(answers) from servers may come in other order. How i can make http request command, that
not return until file is received. Or is there some other method to receive files in right order?
Shortly, i need synchronous query, is that possible?

Thanks
Raimo
karu
Posts: 40
Joined: Mon Feb 24, 2014 10:16 pm

Re: HTTPRequest return order

Post by karu »

I resolved this question with making my own buffer, that will not send next message, until lastone returned
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: HTTPRequest return order

Post by Peter »

perhaps like this way (untested):

Code: Select all

Procedure HttpGetEvent(...

  Static nbRequests = 1

  [YourCode]

  nbRequests + 1

  If nbRequests < 5
    HTTPRequest(#PB_HTTP_Get, "http://127.0.0.1/query.php?nr=" + Str(nbRequests), @HttpGetEvent())
  EndIf
	
EndProcedure

HTTPRequest(#PB_HTTP_Get, "http://127.0.0.1/query.php?nr=1", @HttpGetEvent())
Greetings ... Peter
Post Reply