}
protected PerfMonAgentConnector getConnector(String host, int port) throws IOException {
log.debug("Trying new connector");
SocketAddress addr = new InetSocketAddress(host, port);
Transport transport = null;
try {
transport = TransportFactory.TCPInstance(addr);
if (!transport.test()) {
throw new IOException("Agent is unreachable via TCP");
}
} catch (IOException e) {
log.info("Can't connect TCP transport for host: " + addr.toString(), e);
boolean useUDP = JMeterUtils.getPropDefault("jmeterPlugin.perfmon.useUDP", false);
if (!useUDP) {
throw e;
} else {
try {
log.debug("Connecting UDP");
transport = TransportFactory.UDPInstance(addr);
if (!transport.test()) {
throw new IOException("Agent is unreachable via UDP");
}
} catch (IOException ex) {
log.info("Can't connect UDP transport for host: " + addr.toString(), ex);
throw ex;