开发者

Starting a Process When a Port is Connected To

I want to create a single client that issues unicast requests for data from any of many workstations on the same LAN. The client will likely run Linux, but the workstations may run any OS. Is it possible to avoid running a daemon on each of the workstations and yet have them reply to requests within a few seconds? I want to avoid creating a da开发者_JS百科emon because the service may be infrequently used and I don't want to burden the workstations with another process.


Take a look at suitable implementations of inetd for your target operating system. This service listens for connections, and delegates the actual communication to plain IO through stdin/stdout to an instance of your process (which gets spawned on demand):

The inetd utility [..] listens for connections on certain internet sockets. When a connection is found on one of its sockets, it decides what service the socket corresponds to, and invokes a program to service the request. The server program is invoked with the service socket as its standard input, output and error descriptors. After the program is finished, inetd continues to listen on the socket [..]

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜