Refactoring BIO: new socket-handling functions, deprecate older ones