开发者

RESTful service - questions

I am an experienced C/C++ Application Programmer, but relatively new to Web Programming, REST etc.

There is a central server which monitors various other client machines. The server exposes some APIs by which the client machines periodically send status updates & other things to the server. Though it's client which always contacts the 开发者_高级运维server, the server also sends commands to the client through a response to the POST methods & the client methods act on it.

Now if the server itself pro-actively wants to send some message to client, is this possible - i.e. clients connect only once an hour, but in the middle the server needs to ask the client to contact it - is this possible at all?

If not, is the only way to have some out of band data - i.e. have the clients also run a separate process listening on a separate port. Any time, the server wants to contact the client, the server sends some message to the particular client on that port asking the client to contact the server?


There are two ways of doing this, depending on your exact situations. If your network allows connections from the server to the clients you could expose a minimal webserver or RPC-like interface on your clients and connect to that from your server. If that is not possible, for example because your clients are behind firewalls or NAT gateways, the clients will need to poll the server to see if there are any commands waiting.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜