socket fuction