package vicazh.hyperpool.stream.net;
import java.io.*;
import java.net.*;
class UDPOutStream extends SocketStream {
UDPOutStream(Connection connection, InetAddress address) {
super(connection, new ByteArrayOutputStream(), new Socket(address));
}
public void flush() throws IOException {
super.flush();
byte[] buf = ((ByteArrayOutputStream) outputstream).toByteArray();
DatagramPacket packet = new DatagramPacket(buf, buf.length, getSocket()
.getInetAddress(), ((OutService) connection.element).getPort());
((UDPOutConnection) connection).socket.send(packet);
((ByteArrayOutputStream) outputstream).reset();
}
}
|