Some refactoring of native raw socket code.