abstract socket support

fix #1486

+2 is because we have a prefix 0 and a suffix 0.

I think we should rename strlen2, because strlen kinda
radiates that it will return the size of the string without
the suffix 0. This function returns the total size needed
in memory.