Working code for transmitiing and receiving data over IP