Return Channel
Hi everybody!
I'm a spanish engineer and I am a novice in developing mhp applications. I'd like to know how I can be sure that the connection with a server through the modem is established correctly and I am not doing anything wrong. The code I have implemented is something similar to the following:
// First, we get a reference to the RCInterfaceManager
RCInterfaceManager rcm =
RCInterfaceManager.getInstance();
// Now, we get the list of return channel interfaces that
// are available to our application. This returns all
// the available interfaces
RCInterface[] interfaces = rcm.getInterfaces();
// Now choose which interface we use.
if (interfaces[0] instanceof ConnectionRCInterface) {
// If it's a ConnectionRCInterface, it's not
// permanently connected, so we need to connect it
// first
ConnectionRCInterface myInterface;
myInterface = (ConnectionRCInterface)interfaces[0];
// Now that we've got a reference to the interface, we
// can start to use it
try {
// First,we reserve the connection
myInterface.reserve();
// Set up the connection parameters
ConnectionParameters myConnectionParameters;
myConnectionParameters = new ConnectionParameters
("123456789", "username", "password");
// Then we set the target to point to our phone
// number
myInterface.setTarget(myConnectionParameters);
// Now that we've done that, we can actually connect
myInterface.connect();
// here I'm doing whatever I want to now that I've got a
// connection
// Once we're done, we disconnect the interface and
// release the resource
myInterface.disconnect();
myInterface.release();
} catch (permissionDeniedException e) {
// we can't reserve the interface, so return
return;
}
}
else {
// we have a permanent connection, so just use it
}
I'd appreciate if you could help me as soon as possible.
Thanks in advance.
[2107 byte] By [
livieza] at [2007-10-3 1:24:08]

Really my code is the following, the other one is a skeleton I've used:
try {
//WriteTrace("Que estas haciendo amparo");
RCInterfaceManager rcm = RCInterfaceManager.getInstance();
InetAddress inet = InetAddress.getByName("localhost");
//WriteTrace("Getting ip address");
//RCInterface[] interfaces = rcm.getInterfaces();
RCInterface interfaces = rcm.getInterface(inet);
//WriteTrace("Get interface");
int rcType = interfaces.getType();
if (interfaces instanceof ConnectionRCInterface) {
//WriteTrace("interface[0] instance of ConnectionRCInterfac");
//ConnectionRCInterface myInterface = (ConnectionRCInterface)
ConnectionRCInterface myInterface = (ConnectionRCInterface) interfaces;
try {
//myInterface.reserve(this, null);
ConnectionParameters myConnectionParameters;
myConnectionParameters = new ConnectionParameters("204","", "");
try {
myInterface.setTarget(myConnectionParameters);
}
catch (IncompleteTargetException e) {
//WriteTrace("Error Setting Target");
e.printStackTrace();
}
try {
myInterface.connect();
/*Socket echoSocket = null;
DataOutputStream os = null;
DataInputStream is = null;
DataInputStream stdIn = new DataInputStream(System.in);
try {
echoSocket = new Socket("192.168.1.69",8000);
os = new DataOutputStream(echoSocket.getOutputStream());
is = new DataInputStream(echoSocket.getInputStream());
}
catch (UnknownHostException e) {
System.err.println("Don't know about host: taranis");
}
catch (IOException e) {
System.err.println("Couldn't get I/O for the connection to: taranis");
}
if (echoSocket != null && os != null && is != null) {
try {
String userInput;
os.writeBytes("holaaa");
os.close();
is.close();
echoSocket.close();
}
catch (IOException e) {
System.err.println("I/O failed on the connection to: taranis");
}
}*/
//WriteTrace("Conectado");
}
catch (IOException e) {
//WriteTrace("IO Exception");
e.printStackTrace();
}
myInterface.disconnect();
myInterface.release();
//WriteTrace("Connection ended succesfully");
} catch (PermissionDeniedException e) {
//WriteTrace("Permission Denied Exception");
return;
}
} else {
//WriteTrace("interface[0]NOT__ instance of ConnectionRCInterfac");
}
} catch (UnknownHostException e) {
System.out.println("holaaa");
}
try {
Thread.sleep(4000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
ISN'T IT NECESSARY THAT THE STB HAS AN IP ADDRESS TO EXCHANGE MESSAGES WITH THE SERVER?
Thank you very much