01: package vicazh.hyperpool.stream.net;
02:
03: import java.io.*;
04: import java.net.*;
05:
06: class UDPInStream extends SocketStream {
07:
08: UDPInStream(Connection connection, OutputStream outputstream,
09: InetAddress address) {
10: super (connection, outputstream, new Socket(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: ((UDPInConnection) connection).address,
19: ((UDPInConnection) connection).port);
20: ((UDPInService) connection.element).socket.send(packet);
21: ((ByteArrayOutputStream) outputstream).reset();
22: }
23:
24: public void close() throws IOException {
25: super.close();
26: connection.getClient().close();
27: }
28:
29: }
|