Thanx for Reply Amedeo Michelin
P.s. client is a Client RTSP, Server a server RTSP an thi run on linux
RedHat 7.3....proxy run on Win2000
[Programma Proxy]
package proxyrtsp;
import java.io.*;
import java.net.*;
import java.util.*;
public class ProxyRTSP implements Runnable{
public static final int CLIENT=0;
public static final int SERVER=1;
public static final int OPEN=0;
public static final int CLOSE=1;
public static final int STOP=2;
private Thread portaInAttesa=null;
private ServerSocket scktPortaInAttesa;
private int portaProxy=1080;
private String indirizzoServer="127.0.0.1";
private int portaServer=80;
private boolean logFlag=false;
// private String lingua="it";
public static void main(String[] ingressi){
ProxyRTSP amedeo = new ProxyRTSP(ingressi);
}
private ProxyRTSP(String[] ingressi){
try{
if ( ingressi.length > 0) {
portaProxy = Integer.parseInt(ingressi[0]);
if ( ingressi.length > 1) {
indirizzoServer = ingressi[1];
if ( ingressi.length > 2) {
portaServer = Integer.parseInt(ingressi[2]);
if ( ingressi.length > 3)
logFlag = (Integer.parseInt(ingressi[3])!=0);
//if ( (ingressi.length > 4)&&(ingressi[4]=="en"))
// lingua = ingressi[4];
}
}
}
scktPortaInAttesa = new ServerSocket(portaProxy);
}catch(Exception e){
e.printStackTrace();
return;
}
portaInAttesa = new Thread(this);
portaInAttesa.start();
System.out.println("ProxyRTSP activated on port " + portaProxy
+ " for " + indirizzoServer + ":" + portaServer);
System.out.println("Programm relased by Amedeo
Michelin-Salomon");
System.out.println("Progetto nella materia di Sistemi di
Elaborazione(Ing. Elettronica) ");
System.out.println("Prof. Antonio Puliafito");
System.out.println("Messina(Papardo), Settembre 2002");
}
public void run(){
while(Thread.currentThread()==portaInAttesa){
try{
Socket s=scktPortaInAttesa.accept();
TwinsThread sessioneRTSP=new TwinsThread (s);
}catch(Exception e){
e.printStackTrace();
return;
}
}
}
class TwinsThread {
Socket clientC,
serverS;
RetFlag cont=new RetFlag(OPEN);
ThreadDiConnessione client,
server;
boolean active=true;
TwinsThread(Socket s) throws Exception{
clientC = s;
s.setSoTimeout(0);
InputStream is0=clientC.getInputStream();
InputStreamReader ir0 = new InputStreamReader(is0);
BufferedReader inr0 = new BufferedReader(ir0);
OutputStream os0=clientC.getOutputStream();
OutputStreamWriter or0 = new OutputStreamWriter(os0);
BufferedWriter outr0 = new BufferedWriter(or0);
InputStream is1=serverS.getInputStream();
InputStreamReader ir1 = new InputStreamReader(is1);
BufferedReader inr1 = new BufferedReader(ir1);
OutputStream os1=serverS.getOutputStream();
OutputStreamWriter or1 = new OutputStreamWriter(os1);
BufferedWriter outr1 = new BufferedWriter(or1);
System.out.println("Connection accepted by server!");
client=new ThreadDiConnessione(SERVER, inr0, outr1 );
server=new ThreadDiConnessione(CLIENT, inr1, outr0);
}
class ThreadDiConnessione extends Thread{
int tipo;
BufferedReader is;
BufferedWriter os;
ThreadDiConnessione(int tipo, BufferedReader is,
BufferedWriter os) throws Exception{
ByteArrayOutputStream command = new
ByteArrayOutputStream();
this.tipo=tipo;
this.is=is;
this.os=os;
setDaemon(true);
start();
}
public void run(){
try {while(active){
String line = is.readLine();
line = line + "\n\r";
if(tipo==SERVER) System.out.println("C>" + line);
else System.out.println("S>" + line);
os.write(line, 0 , line.length());
os.flush();
}
}
catch(Exception e){
e.printStackTrace();
return;
};
}
}
}
class RetFlag{
int command;
public RetFlag(int init){command=init;}
public void setValue(int cmd){command=cmd;}
public int getValue(){return command;}
}
}
[Output programma]
C:\JBuilder7\jdk1.3.1\bin\javaw -classpath "C:\Documents and
Settings\amichelin.CERERE\jbproject\ProxyRTSP\classes;C:\JBuilder7\jdk1.3.1\demo\jfc\Java2D\Java2Demo.jar;C:\JBuilder7\jdk1.3.1\jre\lib\i18n.jar;C:\JBuilder7\jdk1.3.1\jre\lib\jaws.jar;C:\JBuilder7\jdk1.3.1\jre\lib\rt.jar;C:\JBuilder7\jdk1.3.1\jre\lib\sunrsasign.jar;C:\JBuilder7\jdk1.3.1\lib\dt.jar;C:\JBuilder7\jdk1.3.1\lib\htmlconverter.jar;C:\JBuilder7\jdk1.3.1\lib\tools.jar"
proxyrtsp.ProxyRTSP 900 192.168.96.157 554 1
ProxyRTSP activated on port 900 for 192.168.96.157:554
Programm relased by Amedeo Michelin-Salomon
Progetto nella materia di Sistemi di Elaborazione(Ing. Elettronica)
Prof. Antonio Puliafito
Messina(Papardo), Settembre 2002
Connection with client accepted!
Connection accepted by server!
C>DESCRIBE rtsp://192.168.96.156:900/esempio1.mp4 RTSP/1.0
C>CSeq: 1
C>Accept: application/sdp
C>User-Agent: Cisco RTSP 1.0
C>
java.net.SocketException: Connection aborted by peer: socket write
error
at java.net.SocketOutputStream.socketWrite(Native Method)
S>RTSP/1.0 200 OK
S>Server: DSS/4.1.1 (Build/412.37; Platform/Linux)
S>Cseq:
S>Last-Modified: Tue, 08 Oct 2002 12:07:14 GMT
at java.net.SocketOutputStream.write(SocketOutputStream.java:83)
at java.io.OutputStreamWriter.flushBuffer(OutputStreamWriter.java:230)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:244)
at java.io.BufferedWriter.flush(BufferedWriter.java:233)
at proxyrtsp.ProxyRTSP$TwinsThread$ThreadDiConnessione.run(ProxyRTSP.java:243)C>null
C>null