added socket marshalling functions