_socket.connect(new InetSocketAddress(address, settings.getPort()), settings.getConnectTimeout());
}
catch (SocketException e)
{
throw new TransportException("Error connecting to broker", e);
}
catch (IOException e)
{
throw new TransportException("Error connecting to broker", e);
}
try
{
IdleTimeoutTicker ticker = new IdleTimeoutTicker(transportActivity, TIMEOUT);
_connection = new IoNetworkConnection(_socket, delegate, sendBufferSize, receiveBufferSize, TIMEOUT, ticker);
ticker.setConnection(_connection);
_connection.start();
}
catch(Exception e)
{
try
{
_socket.close();
}
catch(IOException ioe)
{
//ignored, throw based on original exception
}
throw new TransportException("Error creating network connection", e);
}
return _connection;
}