I have a java server listening on a Socket. I can send and receive data between this java server socket and java client sockets attached to it.
Now I want to connect PHP to the java server (via the java socket) but cannot seem to send a byte array (using pack()) to java.
$socket = fsockopen("127.0.0.1", 5477) or die("Error creating socket");
$output = pack("i3", 2, 1, 1);
fwrite($socket, $output, 3);
On the java end I get a java.io.EOFException when I try to call in.readInt() (where in is a DataInputStream)
if (in.available() != 0)
{
//read the data
int len = in.readInt(); //length of the buffer
}
So what is the problem? / Am I going about this in the correct way or is there a better way to do this?