Define client side socket functions