[lib] build socket object on the fly