Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stream closed error!

Status
Not open for further replies.

rishath

Programmer
Jan 20, 2004
59
US

I have designed a Tunneling Proxy server in java. I have opened an InputStream and OutputStream for a socket. After writing to the socket using the OutputStream, i'm closing only the output stream.
Code:
//ProxyConnection class
try {
   toServer = new Socket(host,port);
   Proxy.display("open connection to:"+toServer+"(timeout="+timeout+" ms)");
   
   
    clientIn = fromClient.getInputStream();
   clientOut = new BufferedOutputStream(fromClient.getOutputStream());
   serverIn = toServer.getInputStream();
   serverOut = new BufferedOutputStream(toServer.getOutputStream());
   
   
  URL u=new URL("anyurl");
    BufferedReader in=new BufferedReader(new InputStreamReader(u.openStream()));
    String str;
    
    while((str=in.readLine())!=null)
    {
        clientOut.write(str.getBytes());
        Proxy.println(str);
               
        
    }
  
    clientOut.close();

while(r0!=0 || r1!=0 || (time1-time0)<=timeout) 
      {
        Proxy.println("r0= "+r0+"r1= "+r1);
        while((r0=clientIn.available())>0) //This is where I get the error 
        { 
                    -------
        }




I get the following error, when I try to use the InputStream for the same socket.
Code:
java.io.IOException: Stream closed.

	at java.net.PlainSocketImpl.available(Unknown Source)
	at java.net.SocketInputStream.available(Unknown Source)
	at ProxyConnection.run(Proxy.java:131)
	at Proxy.run(Proxy.java:249)
	at Proxy.main(Proxy.java:284)

Is there anyway I can use the InputStream of that socket?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top