seperate code for socket/rpc