On 17.02.2013 16:57, Ian MacArthur wrote: > I used named pipes to do this, since they work ok on WIN32 as well as *nix & > OSX. > > My app tests for the presence of the named pipe on launch; if not found it > launches a full instance & creates the pipe... If found, a little helper > function just writes the new file instance onto the pipe then terminates. The > main app "monitors" the incoming pipe for actions, albeit as a low priority > background thread. > > Seems to work ok, but was a bit of messing about with platform specific code > to get the pipes to work "transparently" across platforms. > > There's probably a better way though!
Maybe not better, but for some reasons easier to implement, at least for me: I used a local TCP socket and Fl::add_fd() for this. PRO: platform independent implementation, and Fl::add_fd() works even on Windows, where Fl::add_fd() is restricted to sockets. This was the main argument to do it this way. Also, no threads required. CON: you need a fixed local socket number for it to work. A named pipe would be more flexible (arbitrary NAME vs. socket NUMBER). The app first tries to connect to the socket, and if it exists, sends a message and exits. If it doesn't exist, then this is the first instance of the app. It creates a local server socket and registers it with Fl::add_fd() to watch it. Whenever a new app is started, a callback is triggered in the first instance, since the other instance writes to the socket. The first instance then reads the message from the socket... Albrecht _______________________________________________ fltk mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk

