[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

SIP RTP J2ME development

Posted on 2008-10-13
2
Medium Priority
?
2,246 Views
Last Modified: 2013-11-24
Dear All,
am facing a problem with my code, am trying to initiate an RTP session. I succeeded with implementation of SIP authentication and registry but i cannot get the RTP steam ?
i would appreciate if someone can review my code and pinpoint the errors am facing.
Enclosed both Class for the RTP and the error am getting.
and would be more appreciated if someone can pinpoint a workable sourcecode or document of a complete SIP and RTP under JAVA J2ME.
package sip_server2;
 
//package com.ctimn;
 
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
 
public class SocketListener extends Thread{
 
   private Form outputForm;
   private boolean shutdownFlag = false;
   private StreamConnectionNotifier notifier;
 
   public SocketListener(Form outputForm){
      this.outputForm = outputForm;
   }
 
  
   private StreamConnectionNotifier createNotifier() throws IOException {
      return (StreamConnectionNotifier)
              Connector.open("socket://192.168.2.56:5062", Connector.READ_WRITE, true);
   
 
//"rtp://:16384"
      //"rtp://:5060"
       //"socket://1006@192.168.100.1:5060"
      //"socket://:5060"
  // "sip://1006@192.168.100.1:5060"
 //"socket://127.0.0.1:8888"
//"serversocket://:4444"
   }
 
   public void run(){
      
      System.out.println("socketListener is working"); 
      String dataIn = null;
      String dataOut = null;
      int counter = 1;
      StringItem item = new StringItem("Listening to Socket", "");
      outputForm.append(item);
      StreamConnection connection = null;
      try {
         notifier = createNotifier();
         while (true) {
            try {
               connection = notifier.acceptAndOpen();
            } catch (InterruptedIOException x){
               if (shutdownFlag){
                  return;
               } else {
                  notifier = createNotifier();
               }
            }
            catch(Exception e){    System.out.println("there is no error"+e.getMessage()) ;
            }
            
            DataInputStream is = connection.openDataInputStream();
            DataOutputStream os = connection.openDataOutputStream();
            connection.close();
            try {
               dataIn = is.readUTF();
               System.out.println(dataIn);
               item = new StringItem("Msg: ", "'"+dataIn+"'");
               outputForm.append(item);
               System.out.println("Msg:'"+dataIn+"'");
               dataOut = "Message " + counter + " from the server.";
               counter++;
               os.writeUTF(dataOut);
               os.flush();
            } finally {
                
               System.out.println("finaly try"); 
               os.close();
               is.close();
            }
         }
      } catch (IOException x) {
         System.out.println("Problems sending or receiving data.");
         System.out.println(x.getMessage());
         x.printStackTrace();
      }
     // catch(Exception e){
       // System.out.println("there is no error"+e.getMessage()) ;
      
    // }
   }
 
   public void shutdown(){
      shutdownFlag = true;
   }
}
//Java 2 Micro Edition
//James P. White and David A. Hemphill
//ISBN: 1930110332
//http://manning.com/books/white
 
 
//===========================================================================
//ERROR/
The Exeption:
 
Problems sending or receiving data.
TCP open
javax.microedition.io.ConnectionNotFoundException: TCP open
        at com.sun.midp.io.j2me.socket.Protocol.connect(Protocol.java:216)
        at com.sun.midp.io.ConnectionBaseAdapter.openPrim(ConnectionBaseAdapter.java:103)
        at com.sun.midp.io.j2me.socket.Protocol.openPrim(+108)
        at javax.microedition.io.Connector.openPrim(Connector.java:329)
        at javax.microedition.io.Connector.open(Connector.java:222)
        at sip_server2.SocketListener.createNotifier(SocketListener.java:22)
        at sip_server2.SocketListener.run(SocketListener.java:43)

Open in new window

0
Comment
Question by:deniro1974
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
waleed hassan earned 2000 total points
ID: 22747956
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question