01: package vicazh.hyperpool.stream.net;
02:
03: import java.io.*;
04: import java.net.*;
05:
06: class UDPOutStream extends SocketStream {
07:
08: UDPOutStream(Connection connection, InetAddress address) {
09: super (connection, new ByteArrayOutputStream(), new Socket(
10: address));
11: }
12:
13: public void flush() throws IOException {
14: super .flush();
15: byte[] buf = ((ByteArrayOutputStream) outputstream)
16: .toByteArray();
17: DatagramPacket packet = new DatagramPacket(buf, buf.length,
18: getSocket().getInetAddress(),
19: ((OutService) connection.element).getPort());
20: ((UDPOutConnection) connection).socket.send(packet);
21: ((ByteArrayOutputStream) outputstream).reset();
22: }
23:
24: }
|