The network package [0] provides an extensible API for working with sockets. I'm pleased to announce network-packet-linux [1], a small helper package containing the types needed to use the network package with Linux packet sockets [2].
The documentation [3] provides a short example of using network and network-packet-linux for a simple packet sniffer.