Fixed automatic port allocation in bind_sockets.

bind_sockets should use the same port on IPv4 and IPv6 if port=None.
Merge pull request #977 from schlamar/fix-port-allocation

Fixed automatic port allocation in bind_sockets.