Is this function necessary? Can't you just return the Socket directly from the previous clauses?