PHP client and Java Server Object using a socket?
Posted: Fri Apr 16, 2004 6:42 pm
Hello all!
I believe I'm in the right place for this sort of discussion because I haven't really found any articles or forums that have anything directly related to what I'm doing. Here is a description of what I'm doing:
On a linux server I will be instantiating a java object (which persists until I shut it down) that will create a socket and listen on a certain port number. What it's listening for are strings from a PHP-based web client (which will eventually be commands but I'm in the initial stages right now) and it will output string responses through the same socket to be echoed on the PHP-based web client.
After reviewing many articles on socket programming in both Java and PHP and reading the PHP manual, I've acheived my goal halfway. The PHP web client can establish a connection with the java object and sent a string (the string has been verified as received by the java object).
Here's the problem, when the java object attempts to send out a string to the PHP client, the client never receives the data. The java object looks like it's sending out ok, but fgets or socket_read() do not appear to pick up the string of text that is to be echoed out. The fgets() function returns false every single time and the socket_read() function does not appear to even exist (I get the "call to undefined function" error) even though I have sockets enabled on the module. I'm pretty much out of ideas at this point, does anyone have any thoughts on this? Anything, even theoretical, would be helpful at this point.
Thanks!
Jisoo23
I believe I'm in the right place for this sort of discussion because I haven't really found any articles or forums that have anything directly related to what I'm doing. Here is a description of what I'm doing:
On a linux server I will be instantiating a java object (which persists until I shut it down) that will create a socket and listen on a certain port number. What it's listening for are strings from a PHP-based web client (which will eventually be commands but I'm in the initial stages right now) and it will output string responses through the same socket to be echoed on the PHP-based web client.
After reviewing many articles on socket programming in both Java and PHP and reading the PHP manual, I've acheived my goal halfway. The PHP web client can establish a connection with the java object and sent a string (the string has been verified as received by the java object).
Here's the problem, when the java object attempts to send out a string to the PHP client, the client never receives the data. The java object looks like it's sending out ok, but fgets or socket_read() do not appear to pick up the string of text that is to be echoed out. The fgets() function returns false every single time and the socket_read() function does not appear to even exist (I get the "call to undefined function" error) even though I have sockets enabled on the module. I'm pretty much out of ideas at this point, does anyone have any thoughts on this? Anything, even theoretical, would be helpful at this point.
Thanks!
Jisoo23