ported protocol over to use nssocket