首先,要安装相应的包,daytime 包括被包含在xinetd中
step 1
在终端中输入,sudo apt-get install xinetd 回车
step 2
安装后要简单配置下
sudo gedit /etc/xinetd.d/daytime
我的系统是ubuntu jaunty,其内容如下
# description: An internal xinetd service which gets the current system time
# then prints it out in a format like this: "Wed Nov 13 22:30:27 EST 2002".
# This is the tcp version.
service daytime
{
disable = yes <--此处改为no,即可启用tcp形式对应的服务,下面那个为udp的,按需改就行了
type = INTERNAL
id = daytime-stream
socket_type = stream
protocol = tcp
user = root
wait = no
}
# This is the udp version.
service daytime
{
disable = yes
type = INTERNAL
id = daytime-dgram
socket_type = dgram
protocol = udp
user = root
wait = yes
}
step 3
重启下xinetd服务
在终端中输入
sudo /etc/init.d/xinetd stop 回车
然后
sudo /etc/init.d/xinetd start 回车
step 4
下面开始编程,
这里给出一个例子
}