FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » How to post data without waiting for the response
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
How to post data without waiting for the response [message #170341] Fri, 29 October 2010 17:16 Go to next message
bingomanatee is currently offline  bingomanatee
Messages: 1
Registered: October 2010
Karma: 0
Junior Member
I have a lot of data to transmit - a lot of multi-K files that I want
to send to a web service. I want to do so WITHOUT waiting for the
response. BTW using a simple url, sending a raw body POST.

What is the best way to send the files that is no blocking (because
not dependent on feedback from the recipient)?

Recommendations?
Re: How to post data without waiting for the response [message #170342 is a reply to message #170341] Fri, 29 October 2010 17:30 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
bingomanatee wrote:
> I have a lot of data to transmit - a lot of multi-K files that I want
> to send to a web service. I want to do so WITHOUT waiting for the
> response. BTW using a simple url, sending a raw body POST.
>
> What is the best way to send the files that is no blocking (because
> not dependent on feedback from the recipient)?
>
> Recommendations?

I dont really understand what you are trying to do here.

Where is the PHP involved? On the web service server?


PHP is not an environment that lends itself to background data transmission.
Re: How to post data without waiting for the response [message #170343 is a reply to message #170342] Fri, 29 October 2010 18:10 Go to previous messageGo to next message
Magno is currently offline  Magno
Messages: 49
Registered: October 2010
Karma: 0
Member
On 10/29/2010 02:30 PM, The Natural Philosopher wrote:
> bingomanatee wrote:
>> I have a lot of data to transmit - a lot of multi-K files that I want
>> to send to a web service. I want to do so WITHOUT waiting for the
>> response. BTW using a simple url, sending a raw body POST.
>>
>> What is the best way to send the files that is no blocking (because
>> not dependent on feedback from the recipient)?
>>
>> Recommendations?
>
> I dont really understand what you are trying to do here.
>
> Where is the PHP involved? On the web service server?
>
>
> PHP is not an environment that lends itself to background data
> transmission.

I think the OP could be wanting to send info or files from within PHP to
another server through something like CURL?

If this is the case... I think the best approach would be to launch
another process to do this, with exec() for example.
Re: How to post data without waiting for the response [message #170344 is a reply to message #170343] Fri, 29 October 2010 18:23 Go to previous messageGo to next message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma: 0
Senior Member
Magno wrote:
> On 10/29/2010 02:30 PM, The Natural Philosopher wrote:
>> bingomanatee wrote:
>>> I have a lot of data to transmit - a lot of multi-K files that I want
>>> to send to a web service. I want to do so WITHOUT waiting for the
>>> response. BTW using a simple url, sending a raw body POST.
>>>
>>> What is the best way to send the files that is no blocking (because
>>> not dependent on feedback from the recipient)?
>>>
>>> Recommendations?
>>
>> I dont really understand what you are trying to do here.
>>
>> Where is the PHP involved? On the web service server?
>>
>>
>> PHP is not an environment that lends itself to background data
>> transmission.
>
> I think the OP could be wanting to send info or files from within PHP to
> another server through something like CURL?
>
> If this is the case... I think the best approach would be to launch
> another process to do this, with exec() for example.

If that is the case, then I totally agree.

Could easily exec a background process to fork, handle the data
transfer, and exit when done, silently.

Of course it wouldn't give any guarantee that te data WAS sent.

Or you could write a daemon, that simply looked in a temporary
directory, and uploaded any files it found there.

Or a process run under cron.

That might be more reliable in fact,. because a failed transfer could be
repeated.

It's pretty much the way e.g. sendmail works.

In fact you could probably use a mail system to do it: write a custom
delivery agent and email the files..the delivery agent is invoked if a
special mail address is noted, and does the dirty work. I used to know
how to make sendmail do that.
Re: How to post data without waiting for the response [message #170345 is a reply to message #170344] Fri, 29 October 2010 18:33 Go to previous messageGo to next message
Magno is currently offline  Magno
Messages: 49
Registered: October 2010
Karma: 0
Member
On 10/29/2010 03:23 PM, The Natural Philosopher wrote:
> Magno wrote:
>> On 10/29/2010 02:30 PM, The Natural Philosopher wrote:
>>> bingomanatee wrote:
>>>> I have a lot of data to transmit - a lot of multi-K files that I want
>>>> to send to a web service. I want to do so WITHOUT waiting for the
>>>> response. BTW using a simple url, sending a raw body POST.
>>>>
>>>> What is the best way to send the files that is no blocking (because
>>>> not dependent on feedback from the recipient)?
>>>>
>>>> Recommendations?
>>>
>>> I dont really understand what you are trying to do here.
>>>
>>> Where is the PHP involved? On the web service server?
>>>
>>>
>>> PHP is not an environment that lends itself to background data
>>> transmission.
>>
>> I think the OP could be wanting to send info or files from within PHP
>> to another server through something like CURL?
>>
>> If this is the case... I think the best approach would be to launch
>> another process to do this, with exec() for example.
>
> If that is the case, then I totally agree.
>
> Could easily exec a background process to fork, handle the data
> transfer, and exit when done, silently.
>
> Of course it wouldn't give any guarantee that te data WAS sent.
>
> Or you could write a daemon, that simply looked in a temporary
> directory, and uploaded any files it found there.
>
> Or a process run under cron.
>
> That might be more reliable in fact,. because a failed transfer could be
> repeated.
>
> It's pretty much the way e.g. sendmail works.
>
> In fact you could probably use a mail system to do it: write a custom
> delivery agent and email the files..the delivery agent is invoked if a
> special mail address is noted, and does the dirty work. I used to know
> how to make sendmail do that.

Anyway, I want to add... in case that making a daemon is not possible. I
personally would make a database table to reflect how the work is going
on by process, which I can query later to know if everything went OK.
Re: How to post data without waiting for the response [message #170346 is a reply to message #170341] Fri, 29 October 2010 18:44 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 10/29/2010 1:16 PM, bingomanatee wrote:
> I have a lot of data to transmit - a lot of multi-K files that I want
> to send to a web service. I want to do so WITHOUT waiting for the
> response. BTW using a simple url, sending a raw body POST.
>
> What is the best way to send the files that is no blocking (because
> not dependent on feedback from the recipient)?
>
> Recommendations?

Use a protocol other than http.

Create your own protocol handler on the server and send the data from
the client.

Any protocol (http, ftp, etc.) will wait for a response from the server.
Even basic TCP/IP will need to wait for some acknowledgment at the
TCP/IP level (only 7 packets can be outstanding at one time), but you
won't have to wait for the protocol to acknowledge the receipt.

But I doubt you'll gain a whole lot, unless the server is very busy;
normally the acknowledgments don't take much. Probably the fastest way
is to tar/gzip all the files into one big one, ftp it to the server then
untar/gzip them at the server.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: How to post data without waiting for the response [message #170365 is a reply to message #170341] Sat, 30 October 2010 15:55 Go to previous message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma: 0
Senior Member
On Fri, 29 Oct 2010 10:16:45 -0700 (PDT), bingomanatee wrote:
> I have a lot of data to transmit - a lot of multi-K files that I want
> to send to a web service. I want to do so WITHOUT waiting for the
> response. BTW using a simple url, sending a raw body POST.
>
> What is the best way to send the files that is no blocking (because
> not dependent on feedback from the recipient)?
>
> Recommendations?

You're going to have to wait for a response doing this. That's just how
http works. Request->Response. However...

If you're willing to take a little risk that the files are somehow wrong
and don't need to tell the user this immediately, you can make the wait
for response be very short. That is, may the php program that handles
the request (accepts the files), save them, and then fork off a new
process to actually do something to them. The child process, however
cannot ever communicate back to the user directly -- it'll have to
notify them by other means, like email. See

http://www.php.net/manual/en/pcntl.example.php

for how to start a process that detaches itself from the parent.

--
80. If my weakest troops fail to eliminate a hero, I will send out my
best troops instead of wasting time with progressively stronger
ones as he gets closer and closer to my fortress.
--Peter Anspach's list of things to do as an Evil Overlord
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Displaying RSS Feeds With Javascript2 ...
Next Topic: linking between 2 databases (on different servers)
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 23 23:40:28 GMT 2024

Total time taken to generate the page: 0.02934 seconds