-2

我必须使用单个持久 TCP 连接来实现服务器到服务器的通信协议。该连接两端的服务器均采用“多线程异步事件驱动模型”实现。这两个服务器都是用 C++ 和 Linux 上的 Pthreads 实现的。服务器 A 总是向服务器 B 发送请求,服务器 B 以响应响应。服务器 B 不向服务器 A 发送任何请求,它只是响应它收到的请求。有人可以向我发布此通信的示例代码吗?您能帮我提供服务器 A 和服务器 B 的代码吗?或者请指出我可以找到原型代码的任何旧答案或任何网站。提前致谢。

4

1 回答 1

1

TCP servers cannot open connections to TCP servers. There is no IP protocol for that. One of the two servers must run a TCP client as a subsystem. The exact mechanics of how you do that depend on your client<>server protocol - the 'server-client' could log in to the 'client-server' with a unique username/password, or could use a different server listening port.

It's up to you:)

于 2012-08-02T01:06:51.157 回答