Wrapped the socket library into modules with variants.

It is more readable at usage.