Timeout and persistent connection feature added

Added the possibility to use persistent connection and to set timeout.