-
安装xinetd
sudo yum install xinetd -
配置
举例:xinetd接收到客户端请求后,启动xhttpd的可执行文件,(xhttpd服务器的代码需要自己编写,用于处理/回应请求)
(1)在/etc/xinetd.d/下创建一个名为 xhttpd 的配置文件
注意:等号两边有1个空格,要想补齐必须使用Tab键
service xhttpd
{
socket_type=stream
protocol=tcp
wait=no
user=nobody
server=/usr/local/sbin/httpd/xhttpd # xhttpd是可执行文件,放在/usr/local/sbin/httpd目录下
/server_args=/var/xhttp/mh_html # 浏览器请求的资源所在的目录
disable=no
flags=IPv4
}
(2)vi /etc/services 添加端口
xhttpd 9523/tcp # xhttpd server
xhttpd 9523/udp
(3)重启xinetd服务器sudo service xinetd restart
(4)查看xinetd是否启动成功:ps aux | grep xinetd
root 15607 0.2 0.0 27164 1032 ? Ss 10:24 0:00 /usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid
gjw 15619 0.0 0.0 112724 988 pts/0 S+ 10:24 0:00 grep --color=auto xinetd