added protocol version 4 support and auto-version negotiation.