Establishing a socket connection