added option to choose between TCP or sock for php