Made abstraction for writing to sockets