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]
# 1

The only obvious problem I spotted when I read your code quickly is that your call to reserve() has the wrong parameters.

It's not absolutely necessary to use the API calls in your example. Just opening a socket should automatically establish the connection however you have less control about when it happens, when the connection is closed and if the connection is interrupted. This degree of control may (or may not) be important to your application.

desperadoa at 2007-7-14 18:21:26 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 2

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

livieza at 2007-7-14 18:21:26 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 3
> ISN'T IT NECESSARY THAT THE STB HAS AN IP ADDRESS TO> EXCHANGE MESSAGES WITH THE SERVER?For a modem based return channe, the STB will get an IP address during the PPP connection set-up, just like a PC does when accessing a dial-up ISP.
desperadoa at 2007-7-14 18:21:26 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 4
Ok, I see what you mean but I don't know how to establish a ppp connection because I won't have a permanent connection (only when I need it) and if the server PC has to have a ppp server running, etc.Thank youRegards
livieza at 2007-7-14 18:21:26 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 5

> Ok, I see what you mean but I don't know how to

> establish a ppp connection because I won't have a

> permanent connection (only when I need it) and if the

> server PC has to have a ppp server running, etc.

If the return channel in the STB is a modem then a ppp connection will be automatically be established as part of setting up a connection when you need it.

Whatever you dial must include a ppp server.

desperadoa at 2007-7-14 18:21:26 > top of Java-index,Java Mobility Forums,Consumer and Commerce...