added socket function