From: Naga Kiran K on
Hi Rasmus,

Thanks for reply.
The requirement I was looking for is to read/write given only the file
descriptor number.

PHP-CGI binary is invoked by a webserver that runs in jail-directory and
doesn't have access to the file path directory.
So, it communicates with another daemon that opens a socket to that file and
in turn passes the file descriptor alone.

Can you please suggest if there is any API in PHP that serves this
requirement [read/write to given file descriptor]
Please let me know if I need to provide more information.

Thanks,
Naga Kiran

On Thu, Apr 15, 2010 at 7:33 PM, Rasmus Lerdorf <rasmus(a)lerdorf.com> wrote:

> On 04/15/2010 06:52 AM, Naga Kiran K wrote:
> > Hi,
> >
> > We are upgrading PHP from 5.2.3 to 5.3.2 and are facing few issues [like
> > unsupported functions...]
> >
> > In PHP 5.2.3, "fdopen" was used to read/write to a file descriptor
> > that's opened by another application.
> >
> > fdopen(<fileDescriptorId>,"rw"); //It worked fine with PHP 5.2.3
> >
> > After PHP upgrade,its throwing "undefined reference to 'fdopen'
> function".
> >
> > Please suggest whats the replacement for this in PHP 5.2.3 or any
> > workaround.
>
> PHP has never had an fdopen() function. It must be something in user
> space that provided that for you if you had it.
>
> -Rasmus
>



--
Regards,
Naga Kiran
From: Rasmus Lerdorf on
You seem to be quite confused. First of all, a function like fdopen() which
has never existed in any version of PHP, wouldn't read/write anything. In C
that function will return a FILE pointer from a file descriptor. You would
then use fread()/fwrite() to read and write from that FILE pointer. But PHP
doesn't have file pointers nor file descriptors, so none of this applies to
PHP. In PHP an open file is a resource just like an open database
connection is a resource.

So, is your question really how to read and write to files? There are many
ways to do that. The easiest is to just call
file_get_contents()/file_put_contents(), but you can also use
fopen()/fread()/fwrite() if you prefer that approach.

-Rasmus

On Fri, Apr 16, 2010 at 5:15 AM, Naga Kiran K <k.nagakiran(a)gmail.com> wrote:

> Hi Rasmus,
>
> Thanks for reply.
> The requirement I was looking for is to read/write given only the file
> descriptor number.
>
> PHP-CGI binary is invoked by a webserver that runs in jail-directory and
> doesn't have access to the file path directory.
> So, it communicates with another daemon that opens a socket to that file
> and in turn passes the file descriptor alone.
>
> Can you please suggest if there is any API in PHP that serves this
> requirement [read/write to given file descriptor]
> Please let me know if I need to provide more information.
>
> Thanks,
> Naga Kiran
>
>
> On Thu, Apr 15, 2010 at 7:33 PM, Rasmus Lerdorf <rasmus(a)lerdorf.com>wrote:
>
>> On 04/15/2010 06:52 AM, Naga Kiran K wrote:
>> > Hi,
>> >
>> > We are upgrading PHP from 5.2.3 to 5.3.2 and are facing few issues [like
>> > unsupported functions...]
>> >
>> > In PHP 5.2.3, "fdopen" was used to read/write to a file descriptor
>> > that's opened by another application.
>> >
>> > fdopen(<fileDescriptorId>,"rw"); //It worked fine with PHP 5.2.3
>> >
>> > After PHP upgrade,its throwing "undefined reference to 'fdopen'
>> function".
>> >
>> > Please suggest whats the replacement for this in PHP 5.2.3 or any
>> > workaround.
>>
>> PHP has never had an fdopen() function. It must be something in user
>> space that provided that for you if you had it.
>>
>> -Rasmus
>>
>
>
>
> --
> Regards,
> Naga Kiran
>
 | 
Pages: 1
Prev: Zip Search
Next: Include security?