Advanced socket function