// set up connection to server
String host = args[0];
int port = Integer.parseInt(args[1]);
final Parser parser = new PipeParser();
LowerLayerProtocol llp = new MinLowerLayerProtocol();
Connection connection = new ActiveConnection(parser, llp, new Socket(
host, port));
final Initiator initiator = connection.getInitiator();
connection.activate();
final String outText = "MSH|^~\\&|||||||ACK^^ACK|||R|2.4|\rMSA|AA";
final IDGenerator generator = new InMemoryIDGenerator();
// get a bunch of threads to send messages
for (int i = 0; i < 1000; i++) {
Thread sender = new Thread(new Runnable() {
public void run() {
try {
// get message ID
String ID = generator.getID();
Message out = parser.parse(outText);
Terser tOut = new Terser(out);
tOut.set("/MSH-10", ID);
// send, get response
Message in = initiator.sendAndReceive(out);