memory allocation improvements

remove extra memory allocation in socket_alloc function
link pthread library in makefile