To create the connection: one side listens for connections using runtime.onConnect the other side calls either tabs.connect() (if connecting to a content script) or runtime.connect() (if connecting to a background script).