digitalmars.D.learn - Daemons?
- Daniel Swe (2/2) Aug 15 2007 I'm trying to make a GUI that can display both opengl windows and/or ter...
- Regan Heath (4/14) Aug 15 2007 Named pipes perhaps:
- Deewiant (8/18) Aug 15 2007 What's the problem? Just abstract out the user interface to a separate m...
- Daniel Swe (2/22) Aug 15 2007
- Deewiant (7/10) Aug 15 2007 I'd probably use sockets, as they're practically universally supported a...
- Regan Heath (10/20) Aug 15 2007 Yeah, I was just about to suggest sockets.
- BCS (3/16) Aug 15 2007 sockets would have the nice side effect that you could run the CLI/GUI
- Daniel Swe (2/7) Aug 16 2007
I'm trying to make a GUI that can display both opengl windows and/or terminal windows (using ncurses). So one could start the program using a terminal (using ./test -console for example) at work. But later when I get home I would like a opengl window so I write ./test -opengl , and the same instance of the program that was used for the console would pop up with all the bells and whistles for opengl. The problem is that I don't really know how to do it. Should I make a daemon that guis connect to? Is there any way to find the pid and communicate with the instance using tango? Or is there another more clever way? I'm currently using gdc and Tango in Ubuntu. //With regards Daniel Swe.
Aug 15 2007
Daniel Swe wrote:I'm trying to make a GUI that can display both opengl windows and/or terminal windows (using ncurses). So one could start the program using a terminal (using ./test -console for example) at work. But later when I get home I would like a opengl window so I write ./test -opengl , and the same instance of the program that was used for the console would pop up with all the bells and whistles for opengl. The problem is that I don't really know how to do it. Should I make a daemon that guis connect to? Is there any way to find the pid and communicate with the instance using tango? Or is there another more clever way? I'm currently using gdc and Tango in Ubuntu.Named pipes perhaps: http://open.itworld.com/nl/lnx_tip/08232002/ Regan
Aug 15 2007
Daniel Swe wrote:I'm trying to make a GUI that can display both opengl windows and/or terminal windows (using ncurses). So one could start the program using a terminal (using ./test -console for example) at work. But later when I get home I would like a opengl window so I write ./test -opengl , and the same instance of the program that was used for the console would pop up with all the bells and whistles for opengl. The problem is that I don't really know how to do it. Should I make a daemon that guis connect to? Is there any way to find the pid and communicate with the instance using tango? Or is there another more clever way? I'm currently using gdc and Tango in Ubuntu.What's the problem? Just abstract out the user interface to a separate module (or package, if it grows large enough) and instantiate a different type of object depending on the command line. Or call a different set of functions, or have a global enum which chooses between UIs, but I think the OO approach is cleanest here. -- Remove ".doesnotlike.spam" from the mail address.
Aug 15 2007
I want a single instance of the program. So that when I write ./test -console it doesnt really start a new instance of the program but instead connects to the older instance. Deewiant Wrote:Daniel Swe wrote:I'm trying to make a GUI that can display both opengl windows and/or terminal windows (using ncurses). So one could start the program using a terminal (using ./test -console for example) at work. But later when I get home I would like a opengl window so I write ./test -opengl , and the same instance of the program that was used for the console would pop up with all the bells and whistles for opengl. The problem is that I don't really know how to do it. Should I make a daemon that guis connect to? Is there any way to find the pid and communicate with the instance using tango? Or is there another more clever way? I'm currently using gdc and Tango in Ubuntu.What's the problem? Just abstract out the user interface to a separate module (or package, if it grows large enough) and instantiate a different type of object depending on the command line. Or call a different set of functions, or have a global enum which chooses between UIs, but I think the OO approach is cleanest here. -- Remove ".doesnotlike.spam" from the mail address.
Aug 15 2007
Daniel Swe wrote:I want a single instance of the program. So that when I write ./test -console it doesnt really start a new instance of the program but instead connects to the older instance.I'd probably use sockets, as they're practically universally supported and don't require platform-specific code. If you're willing to go POSIX-only you could also try named pipes, as Regan suggested. See also http://en.wikipedia.org/wiki/Inter-process_communication -- Remove ".doesnotlike.spam" from the mail address.
Aug 15 2007
Deewiant wrote:Daniel Swe wrote:Yeah, I was just about to suggest sockets. If you use named pipes you will have code for windows and code for unix, or you could just ignore windows for your specific case. Once you're done you could polish it up and suggest it gets included in Tango. If you want to do that then take a look at tango.sys.Pipe because a NamedPipe will be almost identical to that. The code to read/write the pipe can be found in tango.sys.Process. ReganI want a single instance of the program. So that when I write ./test -console it doesnt really start a new instance of the program but instead connects to the older instance.I'd probably use sockets, as they're practically universally supported and don't require platform-specific code. If you're willing to go POSIX-only you could also try named pipes, as Regan suggested. See also http://en.wikipedia.org/wiki/Inter-process_communication
Aug 15 2007
Deewiant wrote:Daniel Swe wrote:sockets would have the nice side effect that you could run the CLI/GUI on a different system.I want a single instance of the program. So that when I write ./test -console it doesnt really start a new instance of the program but instead connects to the older instance.I'd probably use sockets, as they're practically universally supported and don't require platform-specific code. If you're willing to go POSIX-only you could also try named pipes, as Regan suggested. See also http://en.wikipedia.org/wiki/Inter-process_communication
Aug 15 2007
Thanks, all of you! I wlll be using sockets. I don't look forward to the message pump though ( needs alot of if's or switches). Daniel Swe Wrote:I'm trying to make a GUI that can display both opengl windows and/or terminal windows (using ncurses). So one could start the program using a terminal (using ./test -console for example) at work. But later when I get home I would like a opengl window so I write ./test -opengl , and the same instance of the program that was used for the console would pop up with all the bells and whistles for opengl. The problem is that I don't really know how to do it. Should I make a daemon that guis connect to? Is there any way to find the pid and communicate with the instance using tango? Or is there another more clever way? I'm currently using gdc and Tango in Ubuntu. //With regards Daniel Swe.
Aug 16 2007