Use char* for port number
Check buffer overlap for snprintf
Refactor: move code from client to cgi/auth