views:

216

answers:

2

I am looking for a better way to pass information between my Firefox extension and .NET application. Currently, I am using text files to pass information one way to the .NET application by using the FileSystemWatcher class. The .NET application watches for new files in a specific directory when the Firefox extension writes to it and then the information is stored in a local SQL Server database. Now, I want to query for information from the FF extension, but I havn't come up with a good way of doing it, besides maybe using the clipboard. Using text files is a bit clunky, so any suggestions would be appreciated.

+2  A: 

If your using .net 3.5+ then consider using named pipes. I've seen them used very effectively to communicate between a firefox extension/plugin and .net apps using the corresponding library/DLL. (The firefox plugin did require a little bit of native c++ code)

Another alternative would be to include some sort of server in your application and let your Firefox extension communicate with that through sockets/tcp. If you use HTTP as your protocol then you could communicate by doing things like hitting http://localhost:12345/getdata?id=1 from your extension. Communicating via HTTP should be relatively easy on both ends, but make sure to do a good threat model so that you identify and mitigate any security issues arising from running a server on the box.

Beyond that I'd do a search for .net/windows IPC and see what other windows IPC mechanisms might fit. They should be more robust than writing text files and registry keys. (I foresee the clipboard route being very brittle.) This question might be a good start.

nick
Thanks for the suggestions. I went with implementing an HTTP server. I created a server class using HttpListener in my .NET app and used XPCOM for sockets in the extension.
John Sheares
A: 

Socket way of local communications can be blocked by firewall or can confuse the user. Memory-mapped files are suited better for the task. Also, if APIs allow, you can use MsgConnect, which was designed for task like yours.

Eugene Mayevski 'EldoS Corp