[PHP] PHP fsockopen with the UNIX abstract namespace

2008-02-13 Thread @4u
Hi,

I have a problem with fsockopen in connection with the UNIX abstract
namespace.

To open a UNIX socket in the abstract namespace I have to add a nul byte
in front of the path.

Unfortunately PHP returns
fsockopen() [function.fsockopen]: unable to connect to unix://:0
(Connection refused)

for unix://\x00/tmp/dbus-whatever which is a bit strange because I
expected at least the error message "fsockopen() [function.fsockopen]:
unable to connect to unix://[NUL byte]/tmp/dbus-whatever:0 (Connection
refused)"

Is this a known issue or do I have to set something in the php.ini?

I would appreciate any ideas how to debug this issue.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP fsockopen with the UNIX abstract namespace

2008-02-13 Thread @4u
Hi,

thanks for your help - unfortunately it doesn't help.

With "stream_socket_client ()" I get the message "unable to connect to
unix://\0/tmp/hald-local/dbus-ZniNmvr5O0 (Connection refused) in
/root/dbus_session.php on line 272" which is at least better, because it
shows the full path.

I verified it with

PHP 5.1.2 (cli) (built: Jul 17 2007 17:32:48)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

(It's a Debian based machine)

and

PHP 5.2.5-pl1-gentoo (cli) (built: Dec 29 2007 11:46:44)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
with eAccelerator v0.9.5.1, Copyright (c) 2004-2006 eAccelerator, by
eAccelerator

(Gentoo)

socket_create and socket_connect produces the following error:

Warning: socket_connect() [function.socket-connect]: unable to connect
[22]: Invalid argument in ...

again verified on both systems and definitely with the right arguments -
 the socket resource and a "[NUL]/tmp/path" string as written in the PHP
manual.

Are their other solutions or known problems? If not, I will maybe post
it as a bug - but wanted to make sure that it's not my fault.

Jochem Maas schrieb:
> @4u schreef:
>> Hi,
>>
>> I have a problem with fsockopen in connection with the UNIX abstract
>> namespace.
>>
>> To open a UNIX socket in the abstract namespace I have to add a nul byte
>> in front of the path.
>>
>> Unfortunately PHP returns
>> fsockopen() [function.fsockopen]: unable to connect to unix://:0
>> (Connection refused)
>>
>> for unix://\x00/tmp/dbus-whatever which is a bit strange because I
>> expected at least the error message "fsockopen() [function.fsockopen]:
>> unable to connect to unix://[NUL byte]/tmp/dbus-whatever:0 (Connection
>> refused)"
> 
> your problem might be version related, but php does have a C level function
> php_stream_sock_open_unix() explicitly for the issue of the NUL byte
> (the NUL byte is seen as the end of a string, unless the string handling
> is binary safe - if I got the lingo correct).
> 
> my first guess would be to use socket_create() in combination with
> socket_connect() instead of fsockopen() and see if that does the trick.
> 
> 
>>
>> Is this a known issue or do I have to set something in the php.ini?
>>
>> I would appreciate any ideas how to debug this issue.
>>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PHP fsockopen with the UNIX abstract namespace

2008-02-13 Thread @4u
Hi again,

Jochem Maas schrieb:
> @4u schreef:
[snip]
> is the connection refused a permissions thing here? can you
> verify that it's possible to connect?

I'm not sure but I don't think so. 1.) we speak about D-BUS and 2.) its
owner and root should always be able to connect to it. Especially the
socket_create test seems interesting - removing the NUL byte results in
this snipplet to work - adding it again results in an invalid argument.

> you might consider attaching php to gdb and seeing where things
> go wrong, if the socket itself is fine and usable and your sure
> then a bug report is in order, no?

Looks like I'll do that (trying gdb) and post a bug report.

> maybe someone smarter cares to comment.

Once more thanks for your help :) I wasn't sure if it was me or PHP -
but with the socket_* function tests it looks like it's something wrong
with PHP and the NUL byte.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Start/stop daemon using php

2008-02-27 Thread @4u
Hi,

You might consider D-BUS for your application and the D-BUS PHP binding
which is available since some days too. This would allow you to start /
stop your C application in a far more secure way than the suggested one.

Please have a look at my original release annoucement at the D-BUS
mailing list:

http://lists.freedesktop.org/archives/dbus/2008-February/009363.html

as well as the download URL:

https://sourceforge.net/project/showfiles.php?group_id=17176&package_id=68954

Even if the application runs on Windows you might be able to use D-BUS
for communication.

Daniel Brown schrieb:
> On Wed, Feb 27, 2008 at 7:51 AM, David Sveningsson <[EMAIL PROTECTED]> wrote:
>> Hi, I've written an application in c which I would like to start/stop as
>>  a daemon in gnu/linux.
>>
>>  The application has the argument "--daemon" which forks the process and
>>  exits the parent. Then it setups a SIGQUIT signal handler to properly
>>  cleanup and terminate. It also maintains a lockfile (with the pid) so
>>  only one instance is allowed.
>>
>>  So, to start this application I created a php site that calls
>>  exec("/path/to/binary --daemon > /dev/null 2> /dev/null").
> 
> You can (and should) write this out like so:
>  exec("/path/to/binary --daemon >> /dev/nul 2>&1",$ret,$err);
> ?>
> 
> The >> means to append to the end of a file.  You can use > on
> /dev/null, since it's not a file, but just a black hole, but you may
> want to get into the habit of redirecting and appending.  The 2>&1
> redirects channel 2 (STDERR) to channel 1 (STDOUT) so that all output
> in this case is sent to /dev/null.  For any output that would
> otherwise be generated, $ret will hold STDOUT data, and $err will hold
> the STDERR code.
> 
>>  Everything is working so far, but I cannot get the application to
>>  receive the SIGQUIT when I start using php and exec. Not even manually
>>  using kill in the shell. It works correctly if I start manually thought.
>>
>>  So, is this possible to do? Doesn't exec allow applications with signal
>>  handlers? Is there some other way to terminate the application?
> 
> You may want to launch it from a BASh script.  I had written out
> an example for someone on this list at the beginning of the month.
> Feel free to check it out and use it, or use any part of it:
> 
> [Download] http://pilotpig.net/code-library/daemonize.sh
> [View Source] http://pilotpig.net/code-library/source.php?f=daemonize.sh
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Large XML manipulation within PHP

2008-04-23 Thread @4u

Hi,

How about expat with custom XML handlers? Should work even with an 32 MB 
memory limit. It will just take some time ...


Have fun

Bastien Koert schrieb:

On 4/23/08, Steve Gula <[EMAIL PROTECTED]> wrote:

I work for a company that has chosen to use XML (Software AG Tamino XML
database) as its storage system for an enterprise application. We need to
make a system wide change to information within the database that isn't
feasible to do through our application's user interface. My solution was
to
unload the XML collection in question, open it, manipulate it, then write
it
back out. Problem is it's a 230+MB file and even with PHP's max mem set to
4096MB (of 8GB available to the system) SimpleXML claims to still run out
of
memory. Can anyone recommend a better way for handling a large amount of
XML
data? Thanks.

--
--Steve Gula

(this email address is used for list communications only, direct contact
at
this email address is not guaranteed to be read)



Can you chunk the data in any way, break it into smaller more managable
peices?



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php