Got messaging working.

Also moved the socket connection to the background script.