Page 1 of 1

PHP client and Java Server Object using a socket?

Posted: Fri Apr 16, 2004 6:42 pm
by jisoo23
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

Posted: Fri Apr 16, 2004 9:35 pm
by timvw
you could do some network sniffing, to find out where the bytes are (not).

Posted: Sat Apr 17, 2004 9:49 am
by BDKR
I've done some stuff with Sockets and PHP, but it's hard to say without seeming code.

I will say one thing. There is much in the way of people using sockets with PHP.

Anyway, show some code.

Cheers,
BDKR