Solaris:侦听端口的套接字(在Linux上等效于/etc/xinetd.d)

我准备了一个脚本,它接受服务器端口上的请求,然后处理用户input,通过相同的端口提供输出,然后死亡。 脚本并不总是运行,而是在某个端口被客户端打开时启动。 我的Linux机器上的(工作)configuration是这样的:

/etc/services test_socket 9876/tcp # TestSocket /etc/xinetd.d/test_socket # default: on # description: blah blah blah service test_socket { port = 9876 socket_type = stream protocol = tcp wait = no user = root server = /export/home/stefano/do_something.php instances = 20 } 

一旦客户端打开端口:9876,“do_something.php”脚本开始接收传入的消息,将其处理并输出结果作为输出,然后closures通信。

我想将上述体系结构迁移/复制到Solaris 10机器。

为了这个目的,我在同一个服务文件上configuration了相同的值:

 /etc/services test_socket 9876/tcp # TestSocket 

但是,然后…作为inetd.d在Solaris10驳回并由svc取代,我怎样才能创build一个清单重现相同的行为?

我试图search文档,但当客户端要求通过服务器端口进行通信时,我无法find任何按需启动的东西。

有谁能够帮助我?

您首先需要使用您的configuration创build一个inetd.conf样式文件。 这应该是非常简单的,就像:

 test_socket stream tcp nowait root /export/.../do_something.php do_something.php 

然后运行该命令将该服务描述导入到smf

 inetconv -i inetd.conf-style-file 

如果您想首先查看在不导入的情况下创build的内容,则可以运行:

 inetconv -n -i inetd.conf-style-file -o /tmp 

请注意,一旦导入到smf ,您将通过inetadm命令pipe理服务,例如:

 inetadm -e svc:/network/test_socket/tcp:default # enable the service inetadm -d svc:/network/test_socket/tcp:default # disable the service inetadm -l svc:/network/test_socket/tcp:default # list the service properties