Code example for Socket

Methods: getInetAddress, getLocalAddress, setSoTimeout

0
	 
	 
	public RTSPThread(Socket s, StreamServer srv) throws SocketException {
		System.out.println("Got connection!");
		this.sock = s;
		s.setSoTimeout(1000*120);	// 120 seconds = 2 minutes before timeout
		this.srv = srv;		
		IP = sock.getLocalAddress().getHostAddress();
		baseDescription = "v=0\n" +
		"o=mocsi 1234567890 1 IN IP4 "+IP+"\n" +
        //"o=mocsi 1234567890 1 IN IP4 "+"192.168.42.108"+"\n" + 
		"s=MOCSI SVMP Thin Client RTP Stream\n" + 
		"i=Thin client video\n" + 
		"t=0 0\n" + 
		"a=range:npt=now-\n" + 
		"c=IN IP4 "+IP+"\n";
		 
		remoteIP = sock.getInetAddress().getHostAddress();		
		Log.e(TAG,"starting session with IP: " + remoteIP);
		sess = srv.openSession("rtsp");	
		if (sess == null)
			Log.e(TAG,"srv.openSession returned null");
		sess.start(remoteIP);