moved socket generation to funcion in module