Encapsulate socket and related API using c++ and exception