Hmm, so I decided that I should just try and use Sockets to get my JSP
to talk to the Mythbackend.
Whenever I try and connect to the server, my backend gets stuck in
what seems to be an infinite loop of waiting for a thread as shown
from the log...
2005-02-23 23:06:33 waiting for a thread..
2005-02-23 23:06:33 waiting for a thread..
2005-02-23 23:06:33 waiting for a thread..
2005-02-23 23:06:33 waiting for a thread..
2005-02-23 23:06:33 waiting for a thread..
2005-02-23 23:06:33 waiting for a thread..
... I have been using mythweb as an example of how to communicate to
the server, but it doesn't seem to work too well.
I am using 0.16 but have been using the code from 0.17 to see how this
stuff is intepreted. I hope the general rules didn't change too much.
I have attached the Java code incase anyone wanted to take a look, but
any other pointers would be great.
Cheers,
Whytey
--
GMAIL is 'da bomb baby....YEAH
I have GMail invites, if you want one, email me direct.
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
public class BackendTest {
final static String HOSTNAME = "myth";
Socket mythSocket = null;
DataOutputStream out = null;
DataInputStream in = null;
public BackendTest() {
System.out.println("Start constructor");
try {
mythSocket = new Socket("192.168.0.100", 6543);
out = new DataOutputStream(mythSocket.getOutputStream());
in = new DataInputStream(mythSocket.getInputStream());
} catch (UnknownHostException e) {
System.err.println("Don't know about host: hostname");
e.printStackTrace();
} catch (IOException e) {
System.err.println(
"Couldn't get I/O for the connection to: hostname");
e.printStackTrace();
}
System.out.println("End constructor");
}
public void open() {
System.out.println("Start open");
System.out.println("Checking proto version");
String ret = sendCommand("MYTH_PROTO_VERSION");
System.out.println(ret);
ret = sendCommand("ANN Playback " + "whytey" + " 0");
System.out.println(ret);
System.out.println("End open");
}
public void run() {
System.out.println("Start run");
System.out.println("End run");
}
public void close() {
System.out.println("Start close");
String ret = sendCommand("DONE");
System.out.println(ret);
try {
mythSocket.close();
} catch (IOException e) {
System.err.println("Error closing the socket");
e.printStackTrace();
}
System.out.println("End close");
}
private String sendCommand(String command) {
System.out.println("Start sendCommand");
command = getCommandIntro(command) + command;
System.out.println(command);
//Send the command
System.out.println("Writing command");
try {
mythSocket.setSoTimeout(25);
out.writeBytes(command);
} catch (IOException e) {
System.err.println("Error sending command: " + command);
e.printStackTrace();
}
//Get the response
System.out.println("Reading response");
String ret = "";
try {
String responseLine = in.readLine();
while (responseLine != null) {
System.out.println("Server: " + responseLine);
ret += responseLine;
}
} catch (IOException e) {
System.err.println("Error recieving response");
e.printStackTrace();
}
System.out.println("End sendCommand");
return ret;
}
/**
* This method creates the introduction to the command which travels across
* the Socket. The command is of the form
* {length of command}{Spaces}<command>, where the spaces AND the length of
* the command make up 8 characters.
*
* @param command The command to be sent.
* @return The introduction to the command.
*/
private String getCommandIntro(String command) {
String intro = "" + command.length();
intro += " ";
intro = intro.substring(0, 8);
return intro;
}
public static void main(String[] args) {
BackendTest bet = new BackendTest();
bet.open();
bet.run();
bet.close();
}
}
_______________________________________________
mythtv-dev mailing list
[email protected]
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-dev