snoyberg/conduit — pull request #139 by anton-dessiatov (2014-03-10 08:32:26+00:00)
Title: Allow to force port binding with an explicit version of IP

Without this patch it could be troublesome to check that your socket really gets bound to a port and protocol requested. Imagine asking to bind to IPv4 "127.0.0.1:1024" while this address is already taken by another process on the same computer. If you use HostIPv4 for your HostPreference, you'll end up without an exception, but with IPv6 port 1024 bound, which is counterintuitive (at least for me). To check if you are really bound with v4, you'll have to implement afterBind handler inspecting a socket and throwing exception if something is wrong.

This patch allows you to tell "bind with IPv4 only and throw an exception if you fail" without an afterBind hack.