系统:ubuntu 12.04
1.安装xinetd
#apt-get install xinetd
2.编写自己的一个程序
#vim /workspace/hello.c
###################################
#include
#include
#include
void main(void){
printf("Welcom!
Hello! World!
");
}
###################################
#gcc -o hello hello.c //编译生成hello可执行文件
3.修改/etc/xinetd.conf
添加如下内容
service demobin
{
socket_type = stream
protocol = tcp
wait = no
user = root
server = /home/junxianchen/workspace/test/hello
}
4.修改/etc/service
添加如下内容
demobin 20001/tcp
5.重启xinetd服务
#/etc/init.d/xinetd restart
6测试
#telnet localhost demobin
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Welcom!
Hello! World!
Connection closed by foreign host.
测试成功