working code that connects to localhost inorder to submit an event