1
2
3
4 package ca.uhn.hl7v2.protocol.impl;
5
6 import java.io.IOException;
7 import java.net.Socket;
8 import java.net.SocketAddress;
9
10 import ca.uhn.hl7v2.protocol.TransportException;
11
12
13
14
15
16
17
18 public class ClientSocketStreamSource extends SocketStreamSource {
19
20 private final SocketAddress myAddress;
21 private Socket mySocket;
22
23
24
25
26 public ClientSocketStreamSource(SocketAddress theAddress) {
27 myAddress = theAddress;
28 }
29
30
31
32
33 public Socket getSocket() {
34 return mySocket;
35 }
36
37
38
39
40 public void connect() throws TransportException {
41 mySocket = getSocket(myAddress);
42 }
43
44 private Socket getSocket(SocketAddress theAddress) throws TransportException {
45 Socket s = new Socket();
46 try {
47 s.connect(theAddress);
48 } catch (IOException e) {
49 throw new TransportException(e);
50 }
51 return s;
52 }
53
54 }