class AsyncConnection {

    protected final WritableChannel writableChannel;
    protected final boolean isServer;
    protected InetSocketAddress inetSocketAddress;
    protected boolean closed;

    public AsyncConnection(WritableChannel writableChannel, boolean isServer) {
        this.writableChannel = writableChannel;
        this.isServer = isServer;
    }

    public abstract void handle(NetBuffer buffer);

    public abstract ByteBuffer getPacketLengthByteBuffer();

    public abstract int getPacketLength();

    public WritableChannel getWritableChannel() {
        return writableChannel;
    }

    public String getHostAndPort() {
        return writableChannel.getHost() + ":" + writableChannel.getPort();
    }

    public InetSocketAddress getInetSocketAddress() {
        return inetSocketAddress;
    }

    public void setInetSocketAddress(InetSocketAddress inetSocketAddress) {
        this.inetSocketAddress = inetSocketAddress;
    }

    public void close() {<FILL_FUNCTION_BODY>}

    public boolean isClosed() {
        return closed;
    }

    public void checkClosed() {
        if (closed) {
            String msg = "Connection[" + inetSocketAddress.getHostName() + "] is closed";
            throw DbException.get(ErrorCode.CONNECTION_BROKEN_1, msg);
        }
    }

    public void handleException(Exception e) {
    }

    public void checkTimeout(long currentTime) {
    }

    public boolean isShared() {
        return false;
    }

    public int getSharedSize() {
        return 0;
    }

    public int getMaxSharedSize() {
        return 0;
    }

    public boolean isServer() {
        return isServer;
    }
}

        closed = true;
        if (writableChannel != null) {
            writableChannel.close();
        }
    
<no_super_class>