如何做一个网关

如何做一个网关

问题描述:

大家好,

我需要这个任务的方向:confused:

我有许多客户正在连接我的服务.这些客户端中的每个客户端都会发送一个请求,我将处理该请求并将其发送到服务器以获取响应,然后再次将其发送回发送该请求的客户端.

到目前为止,我已经通过在每个工作程序套接字中登录/注销来访问服务器的解决方案,但是登录过程非常耗时,因此我不得不提出另一种方法.

我想通过一个处理与服务器所有通信的类将所有工作套接字请求路由到服务器.

我确定解决方案已经存在,但到目前为止,我的谷歌搜索功能还没有将我带到任何地方.

任何建议或链接都​​非常有用:)

Hi guys,

I need a point of direction with this task :confused:

I have a number of clients connecting to my service. Each of these clients send a request which I process and send to a server to get a response, Which again is send back to the client who send the request.

So far I''ve made the solution with logon/logoff in each worker socket to access server, but the logon process is time comsuming so I have to come up with an other approach.

I want to route all my worker sockets request to the server through one class that handles all communication with the server.

I''am sure the solution is out there, but my googling has''nt lead me anywhere so far.

Any suggestion or links woud be much appriciated :)

如果您的服务使用HTTP,那么您想要的就是所谓的反向代理".您的客户端可以使用代理进行身份验证(建立会话),然后可以将请求传递给您的服务器.例如,Apache可以开箱即用".谷歌反向代理"的想法.如果您使用其他套接字协议,请看看反向代理如何工作并借用"您认为有用的想法.
If your service uses HTTP, then what you want is called a ''Reverse Proxy''. Your clients can authenticate (set up a session) with the proxy, which can then pass on requests to your server. Apache, for example, can do this "out of the box". Google ''reverse proxy'' for ideas. If you use some other socket protocol, then have a look at how reverse proxies work and ''borrow'' the ideas you find helpful.