change socket to use a table of function pointers instead of a huge switch