www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - inetd or super-server in D :-)

reply Robert <robertospara gmail.com> writes:
I code super-server in D(simple implementation of something like "inetd" does).
To select attempt of connection I use modules of class Selector. My problems:
- how super-server can realize the port of connection request of the client, to
provide proper request-handle procedure?
-after "fork" do I just trigger "exec" with proper server as an argument of the
function   ?
-should I trigger everything via TCPD? (because simple version with
exec(serverd,....) doesn't work properly on my ubuntu)?
- to close all file descriptors I have problem with usage of NOFILE const or
RLIMIT_NOFILE?
how this thing should look in D?
Thanks for any tips. 
Sep 16 2008
next sibling parent reply Janderson <ask me.com> writes:
Robert wrote:
 I code super-server in D(simple implementation of something like "inetd"
does). To select attempt of connection I use modules of class Selector. My
problems:
 - how super-server can realize the port of connection request of the client,
to provide proper request-handle procedure?
 -after "fork" do I just trigger "exec" with proper server as an argument of
the function   ?
 -should I trigger everything via TCPD? (because simple version with
exec(serverd,....) doesn't work properly on my ubuntu)?
 - to close all file descriptors I have problem with usage of NOFILE const or
RLIMIT_NOFILE?
 how this thing should look in D?
 Thanks for any tips. 
Hi Robert I don't have the answer to your problem, sorry. However you might try posting in your native language as well. You might get lucky. -Joel
Sep 16 2008
next sibling parent Robert <robertospara gmail.com> writes:
Janderson Wrote:

 Robert wrote:
 I code super-server in D(simple implementation of something like "inetd"
does). To select attempt of connection I use modules of class Selector. My
problems:
 - how super-server can realize the port of connection request of the client,
to provide proper request-handle procedure?
 -after "fork" do I just trigger "exec" with proper server as an argument of
the function   ?
 -should I trigger everything via TCPD? (because simple version with
exec(serverd,....) doesn't work properly on my ubuntu)?
 - to close all file descriptors I have problem with usage of NOFILE const or
RLIMIT_NOFILE?
 how this thing should look in D?
 Thanks for any tips. 
Hi Robert I don't have the answer to your problem, sorry. However you might try posting in your native language as well. You might get lucky.
How?
 -Joel
Sep 16 2008
prev sibling parent reply Robert <robertospara gmail.com> writes:
Janderson Wrote:

 Robert wrote:
 I code super-server in D(simple implementation of something like "inetd"
does). To select attempt of connection I use modules of class Selector. My
problems:
 - how super-server can realize the port of connection request of the client,
to provide proper request-handle procedure?
 -after "fork" do I just trigger "exec" with proper server as an argument of
the function   ?
 -should I trigger everything via TCPD? (because simple version with
exec(serverd,....) doesn't work properly on my ubuntu)?
 - to close all file descriptors I have problem with usage of NOFILE const or
RLIMIT_NOFILE?
 how this thing should look in D?
 Thanks for any tips. 
Hi Robert I don't have the answer to your problem, sorry. However you might try posting in your native language as well. You might get lucky.
So my english is so bad?
 -Joel
Sep 16 2008
parent reply Janderson <ask me.com> writes:
Robert wrote:
 Janderson Wrote:
 
 Robert wrote:
 I code super-server in D(simple implementation of something like "inetd"
does). To select attempt of connection I use modules of class Selector. My
problems:
 - how super-server can realize the port of connection request of the client,
to provide proper request-handle procedure?
 -after "fork" do I just trigger "exec" with proper server as an argument of
the function   ?
 -should I trigger everything via TCPD? (because simple version with
exec(serverd,....) doesn't work properly on my ubuntu)?
 - to close all file descriptors I have problem with usage of NOFILE const or
RLIMIT_NOFILE?
 how this thing should look in D?
 Thanks for any tips. 
Hi Robert I don't have the answer to your problem, sorry. However you might try posting in your native language as well. You might get lucky.
So my english is so bad?
 -Joel
Hi Robert, I didn't mean any offense by my message. Also note I'm not the best English speaker in the world myself, even though it is my native language. I've put * where I've made comments. If I was to translate what I thought you meant I would write:
 I code super-server in D(simple implementation of something like 
"inetd" does). To select attempt of connection I use modules of class Selector. My problems: I coded a super-server in D which is similar to "inetd". To initate a connection I used the class Selector Module. Anyway how can I solve these problems: * ? What is super-server. Context would help when trying to translate this.
 - how super-server can realize the port of connection request of 
the client, to provide proper request-handle procedure? * I'm not exactly sure what you mean here but I'll take 2 stabs * - How can I find the port the client made the request on. - How can I hand shake with the client to make a connection to the server.
 -after "fork" do I just trigger "exec" with proper server as an 
argument of the function ? - Do I trigger "exec" with the ??proper server?? as an argument of the function after a "fork"? * ?? What is proper server?
 -should I trigger everything via TCPD? (because simple version with 
exec(serverd,....) doesn't work properly on my ubuntu)? - should I trigger everything via TCPD? The simple version with exec(serverd,....) doesn't work properly on ubuntu for me. * Ok, I think that was written in an understanding way ;)
 - to close all file descriptors I have problem with usage of NOFILE 
const or RLIMIT_NOFILE? - NOFILE const or RLIMIT_NOFILE doesn't seem to close all file descriptors. Any suggestions? * Technically you might provide more information here.
 how this thing should look in D?
How would the code for my app look in D? I guess if someone took a little more time they may have been able to translate some of what you where asking. I guess one of the main things you do is leave out "a"'s and "the"'s. I hope that was helpful. -Joel
Sep 17 2008
parent reply Benji Smith <dlanguage benjismith.net> writes:
Janderson wrote:
 * ? What is super-server. Context would help when trying to translate this.
 
  >>> - how super-server can realize the port of connection request of 
 the client, to provide proper request-handle procedure?
 
 * I'm not exactly sure what you mean here but I'll take 2 stabs *
 
 - How can I find the port the client made the request on.
 - How can I hand shake with the client to make a connection to the server.
 
  >>> -after "fork" do I just trigger "exec" with proper server as an 
 argument of the function   ?
 
 - Do I trigger "exec" with the ??proper server?? as an argument of the 
 function after a "fork"?
 
 * ?? What is proper server?
I understood the question. A "super server" is terminology for a linux daemon like "inted" or "xinetd" which listens for certain incoming protocol events, determines the appropriate server to invoke, and passes the request to that server. A super server allows a single daemon to manage the servers for a bunch of different protocols, so that you can consolidate their configuration (and you don't need to have, for example pop3d, running 24 hours a day; only when pop3 requests are handled). Having said all that, I don't know anything about how to implement a super server in D. But I thought the questions were unambiguous, at least for someone who knows the background info about linux daemons. --benji
Sep 17 2008
parent Janderson <ask me.com> writes:
Benji Smith wrote:
 Janderson wrote:
 * ? What is super-server. Context would help when trying to translate 
 this.

  >>> - how super-server can realize the port of connection request of 
 the client, to provide proper request-handle procedure?

 * I'm not exactly sure what you mean here but I'll take 2 stabs *

 - How can I find the port the client made the request on.
 - How can I hand shake with the client to make a connection to the 
 server.

  >>> -after "fork" do I just trigger "exec" with proper server as an 
 argument of the function   ?

 - Do I trigger "exec" with the ??proper server?? as an argument of the 
 function after a "fork"?

 * ?? What is proper server?
I understood the question. A "super server" is terminology for a linux daemon like "inted" or "xinetd" which listens for certain incoming protocol events, determines the appropriate server to invoke, and passes the request to that server. A super server allows a single daemon to manage the servers for a bunch of different protocols, so that you can consolidate their configuration (and you don't need to have, for example pop3d, running 24 hours a day; only when pop3 requests are handled). Having said all that, I don't know anything about how to implement a super server in D. But I thought the questions were unambiguous, at least for someone who knows the background info about linux daemons. --benji
Knowing the lingo sure would help. I thought someone might be able to figure out Roberts email based off the keywords. It was possible that given the way it was written that it was something that Robert had made so I thought I'd better speak up, rather then let Roberts question fall to the wayside. I guess I should have asked the all-knowing google first. -Joel
Sep 17 2008
prev sibling next sibling parent Lars Ivar Igesund <larsivar igesund.net> writes:
Robert wrote:

 I code super-server in D(simple implementation of something like "inetd"
 does). To select attempt of connection I use modules of class Selector. My
 problems: - how super-server can realize the port of connection request of
 the client, to provide proper request-handle procedure?
 -after "fork" do I just trigger "exec" with proper server as an argument
 of the function   ? -should I trigger everything via TCPD? (because simple
 version with exec(serverd,....) doesn't work properly on my ubuntu)? - to
 close all file descriptors I have problem with usage of NOFILE const or
 RLIMIT_NOFILE? how this thing should look in D? Thanks for any tips.
Can I suggest that you look at the io.selector package in Tango? -- Lars Ivar Igesund blog at http://larsivi.net DSource, #d.tango & #D: larsivi Dancing the Tango
Sep 17 2008
prev sibling next sibling parent Tristam MacDonald <swiftcoder gmail.com> writes:
Robert wrote:
 -after "fork" do I just trigger "exec" with proper server as an argument of
the function   ?
In theory yes, this is how mush *nix daemons are implemented. The launcher program forks, execs the server program in the child process, and then exits from the parent process. Note that the server process will share the parent proccess' stdin/stdout/stderr, unless you explicitly change them.
Sep 19 2008
prev sibling parent reply "Chris R. Miller" <lordsauronthegreat gmail.com> writes:
Robert wrote:
 I code super-server in D(simple implementation of something like "inetd"
does). To select attempt of connection I use modules of class Selector. My
problems:
 - how super-server can realize the port of connection request of the client,
to provide proper request-handle procedure?
 -after "fork" do I just trigger "exec" with proper server as an argument of
the function   ?
 -should I trigger everything via TCPD? (because simple version with
exec(serverd,....) doesn't work properly on my ubuntu)?
 - to close all file descriptors I have problem with usage of NOFILE const or
RLIMIT_NOFILE?
 how this thing should look in D?
 Thanks for any tips. 
http://www.enderunix.org/docs/eng/daemon.php This is the definitive guide for server programming on UNIX platforms. Note that most of these functions are hiding in unistd.h. You can get them by importing the D bindings to the C standard library.
Sep 19 2008
parent "Bruce Adams" <tortoise_74 yeah.who.co.uk> writes:
On Fri, 19 Sep 2008 19:16:41 +0100, Chris R. Miller  
<lordsauronthegreat gmail.com> wrote:

 Robert wrote:
 I code super-server in D(simple implementation of something like  
 "inetd" does). To select attempt of connection I use modules of class  
 Selector. My problems:
 - how super-server can realize the port of connection request of the  
 client, to provide proper request-handle procedure?
 -after "fork" do I just trigger "exec" with proper server as an  
 argument of the function   ?
 -should I trigger everything via TCPD? (because simple version with  
 exec(serverd,....) doesn't work properly on my ubuntu)?
 - to close all file descriptors I have problem with usage of NOFILE  
 const or RLIMIT_NOFILE?
 how this thing should look in D?
 Thanks for any tips.
http://www.enderunix.org/docs/eng/daemon.php This is the definitive guide for server programming on UNIX platforms. Note that most of these functions are hiding in unistd.h. You can get them by importing the D bindings to the C standard library.
Ah 2001 before spelling hit the internet. Its nice to have standarts. That's a handy link. Its also work looking at Stevens - "Advanced Programming in the Unix Environment": http://www.amazon.com/Programming-Environment-Addison-Wesley-Professional-Computing/dp/0201563177 And the art of unix programming is woth a read too: http://www.faqs.org/docs/artu/
Sep 20 2008