~ Fix sockets related portability issue.
~ Adapt changes from network-bittorrent.