sockets.d: support bind(), refactor a lot