PHP client and Java Server Object using a socket?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jisoo23
Forum Newbie
Posts: 1
Joined: Fri Apr 16, 2004 6:42 pm

PHP client and Java Server Object using a socket?

Post 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
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

you could do some network sniffing, to find out where the bytes are (not).
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post 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
Post Reply