Image

Imageolithered wrote in Imagephp

more on sockets and servlets

As I mentioned here and here, I've been battling to get some php socket code running under Tomcat.

Just in case somebody might find this useful in the future...



The default php servlet is buggy.

This one works beautifully. Except it doesn't support sockets. That was the root of my previous problem.

After persevering with the default servlet, I did get it running (I think the crucial thing was to set the PATH variable and then reboot). However, I then discovered that PHP_NORMAL_READ is broken on the win32 platform.

So the next thing was to refactor the code to use fsockopen() and fgets() instead of the raw socket functions.

And after all that, Tomcat crashes:

----
[2004-09-23 14:25:40] [info] JNI An unexpected exception has been detected in native code outside the VM.
[2004-09-23 14:25:40] [info] JNI Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred at PC=0x19ED586A
----


So it looks like I'm gonna be using Apache. I think I should have given up on this much earlier...


Now for some php5 weirdness:


Using php5 with Tomcat (the above was php4, which does work for simple scripts), I get blank pages instead of output. Except for a script containing phpinfo()!

I have set "display_errors = on", and scripts run fine in Apache.

The following will work, although is of limited use:
----
<?php
echo "hi";
phpinfo();
?>
----


While this gives no output:
----
<?php
echo "hi";
//phpinfo();
?>
----


WTF!?