We want to use the discard port correctly, so a htons() was missing. Also we need to set it correctly depending on address family. Review provided by danieldg
The third argument for connect should be dependent on the address family. Issue spotted by piebeer who also wrote the patch.