Writing socket objects