de.unkrig.commons.net.stream
Class ActiveSocketOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by de.unkrig.commons.net.stream.ActiveSocketOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable

public class ActiveSocketOutputStream
extends java.io.OutputStream

An OutputStream that connects to a remote server and sends all data to that server. If the connection cannot be established or breaks, the data is silently discarded, but reconnection attempts are made every now and then.


Constructor Summary
ActiveSocketOutputStream(java.net.InetAddress addr, int port)
           
ActiveSocketOutputStream(java.net.InetSocketAddress remoteAddress)
           
ActiveSocketOutputStream(java.net.InetSocketAddress remoteAddress, java.net.InetSocketAddress localAddress)
           
ActiveSocketOutputStream(java.lang.String hostname, int port)
           
 
Method Summary
 void close()
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.io.OutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ActiveSocketOutputStream

public ActiveSocketOutputStream(@NotNull
                                java.net.InetAddress addr,
                                int port)

ActiveSocketOutputStream

public ActiveSocketOutputStream(@NotNull
                                java.lang.String hostname,
                                int port)

ActiveSocketOutputStream

public ActiveSocketOutputStream(@NotNull
                                java.net.InetSocketAddress remoteAddress)

ActiveSocketOutputStream

public ActiveSocketOutputStream(@NotNull
                                java.net.InetSocketAddress remoteAddress,
                                @Nullable
                                java.net.InetSocketAddress localAddress)
Parameters:
remoteAddress - See Socket.connect(java.net.SocketAddress)
localAddress - See Socket.bind(java.net.SocketAddress)
Method Detail

write

public void write(int b)
           throws java.io.IOException
Specified by:
write in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws java.io.IOException
Overrides:
write in class java.io.OutputStream
Throws:
java.io.IOException

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.OutputStream
Throws:
java.io.IOException