class Graphite implements GraphiteSender {

    @Override
    public void connect() throws IllegalStateException, IOException {
        if (isConnected()) {
            throw new IllegalStateException("Already connected");
        }
        InetSocketAddress address = this.address;
        // the previous dns retry logic did not work, as address.getAddress would always return the cached value
        // this version of the simplified logic will always cause a dns request if hostname has been supplied.
        // InetAddress.getByName forces the dns lookup
        // if an InetSocketAddress was supplied at create time that will take precedence.
        if (address == null || hostname != null) {
            address = new InetSocketAddress(InetAddress.getByName(hostname), port);
        }

        if (address.getAddress() == null) {
            throw new UnknownHostException(address.getHostName());
        }

        this.socket = socketFactory.createSocket(address.getAddress(), address.getPort());
        this.writer = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream(), charset));
    }

    public  Graphite(String hostname, int port);
    public  Graphite(String hostname, int port, SocketFactory socketFactory);
    public  Graphite(String hostname, int port, SocketFactory socketFactory, Charset charset);
    public  Graphite(InetSocketAddress address);
    public  Graphite(InetSocketAddress address, SocketFactory socketFactory);
    public  Graphite(InetSocketAddress address, SocketFactory socketFactory, Charset charset);

}