01: package vicazh.hyperpool.stream.net;
02:
03: import java.io.*;
04: import vicazh.hyperpool.stream.*;
05:
06: class OutConnection extends Connection {
07: OutConnection(Element element) {
08: super (element);
09: }
10:
11: private java.net.Socket socket;
12:
13: public void setClient(OutputStream outputstream) throws IOException {
14: socket = ((OutService) element).address == null ? new java.net.Socket(
15: ((OutService) element).getHost(),
16: ((OutService) element).getPort())
17: : new java.net.Socket(((OutService) element).address,
18: ((OutService) element).getPort());
19: socket.setSoTimeout(((OutService) element).timeout);
20: setClient(new SocketStream(this , new BufferedOutputStream(
21: socket.getOutputStream()), new Socket(socket)));
22: Transfer.start(
23: new BufferedInputStream(socket.getInputStream()),
24: getServer());
25: }
26:
27: public void close() {
28: try {
29: socket.close();
30: } catch (Exception e) {
31: }
32: super.close();
33: }
34: }
|