Socket and bind logic