Modularized all sockets functions