Prior to this change it appears the SOCKS5 port parsing was erroneously
used for the SOCKS4 error message, and as a result an incorrect port
would be shown in the error message.
Thanks, landed in 6d43664. I worked on those lines last but I didn't catch it. It's been like that since it was added in 2006, see a15d107. My guess is it was copied over from some SOCKS5 error message parsing since in a SOCKS5 response the port comes after the ip address.