Rewite the sockopt code to be table-driven.