Linux:如何使xinetd可以使用守护程序/服务? [英] Linux: How to make a daemon/service usable with xinetd?

查看:107
本文介绍了Linux:如何使xinetd可以使用守护程序/服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都知道服务器与xinetd一起使用需要进行哪些更改?

Anybody knows what changes are necessary for a server to work with xinetd ?

该服务器是在Linux上运行的.NET邮件服务器.

The server being a .NET mailserver that runs on Linux.

请参阅此帖子的底部以供参考: Lumisoft邮件服务器论坛帖子

See the bottom of this post for reference: Lumisoft Mailserver Forum Post

注意:xinetd,不是单一服务. [x] inetd是一个互联网超级服务器.
超级服务器按需启动服务器服务.
(与服务器服务连续运行相反,这是单服务所做的事情)

Note: xinetd, not mono-service. [x]inetd is an internet superserver.
A superserver starts a server service on demand.
(As opposed to the server service running continuously, which is what mono-service does)

推荐答案

inetd服务与独立服务器的运行方式不同. inetd服务读取stdin并将其写入stdout,让inetd处理TCP/IP的细节,而不是跟踪自己的套接字.如果要使服务器在inetd下运行,则必须执行相同的操作.

An inetd service runs differently from a standalone server. inetd services read stdin and write to stdout, letting inetd handle the gory details of TCP/IP, rather than keeping track of their own sockets. If you want to make a server run under inetd, it'll have to do the same.

以下程序在我的机器上的xinetd下运行良好:

The following program runs just fine under xinetd on my machine:

#include <iostream>
#include <string>

using namespace std;  // yeah, i'm lazy.

int main()
{
    string name;
    cout << "What's your name? " << flush;
    cin >> name;
    cout << "Hi, " << name << "!" << endl;
}

请注意,我根本不担心套接字-xinetd会安排事务,以便该服务可以读取标准输入并写入标准输出.在大多数情况下,您就像在控制台上运行一样编写应用程序.套接字详细信息在服务的配置文件中指定. (请注意,您也许可以使用stdin/stdout来获取/设置套接字的详细信息,这可能是实际的套接字-我不确定-但您确实应该将其留给inetd.)

Note i'm not at all worried about sockets -- xinetd arranges things so that the service can read standard input and write to standard output. You just write your app like you'd be running it on the console, for the most part. The socket details are specified in the config file for the service. (Note, you might be able to get/set details about the socket using stdin/stdout, which may be the actual socket -- i'm not sure -- but you really should leave that stuff up to inetd.)

这篇关于Linux:如何使xinetd可以使用守护程序/服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆