简体   繁体   English

tcp和http连接侦听器可以互相交互吗?

[英]Can tcp and http connection listeners can interact with each other or not?

Is there a way in which the http connection and tcp connection listeners can interact with each other? 是否存在http连接和tcp连接侦听器可以相互交互的方式?

I have two separate application modules one is working through http and other requires tcp . 我有两个独立的应用程序模块,一个是通过http工作,另一个是需要tcp。 I need to do an interaction between these two modules so is there way i can make my http based module interact with tcp based module. 我需要在这两个模块之间进行交互,这样我才能使基于http的模块与基于tcp的模块进行交互。

First of all, you need to read up a little on networking concepts. 首先,您需要阅读一些关于网络概念的内容。 HTTP is what's known as an application level protocol, whereas TCP is what's known as a transport layer protocol. HTTP就是所谓的应用程序级协议,而TCP就是所谓的传输层协议。 Take a look at the OSI Network Model . 看看OSI网络模型

As an example, you can imagine that TCP is the telephone network. 例如,您可以想象TCP是电话网络。 It gives you the basic means to connect to another person and speak with them. 它为您提供了连接另一个人并与他们交谈的基本方法。 However, in order to actually communicate you need to speak the same language, such as English or French. 但是,为了实际沟通,您需要使用相同的语言,例如英语或法语。 That is the application level protocol, HTTP in your case. 这就是应用程序级协议,在您的情况下为HTTP

So to answer your question, in order for your two applications to to communicate and exchange data they need to make a connection / call using TCP and both be speaking the same language / application level protocol namely HTTP . 因此,为了回答您的问题,为了让您的两个应用程序进行通信和交换数据,他们需要使用TCP进行连接/调用, 并且两者都使用相同的语言/应用程序级协议即HTTP

Two distinct processes won't be able to use the same IP port on a same IP address. 两个不同的进程将无法在同一IP地址上使用相同的IP端口。 Thus, two processes won't be able to use the same incoming stream of data coming out of the TCP connection. 因此,两个进程将无法使用来自TCP连接的相同传入数据流。 If they use different ports, there's no problem. 如果他们使用不同的端口,没有问题。

If the two processes use the same IP port, as HTTP is a protocol that sits on top of TCP, it means that your TCP process can be used as a pipe by the HTTP process. 如果这两个进程使用相同的IP端口,因为HTTP是位于TCP之上的协议,这意味着您的TCP进程可以被HTTP进程用作管道。 The TCP process will connect to the IP port, do its stuff, and forward the data to the HTTP process that will handle it. TCP进程将连接到IP端口,执行其操作,并将数据转发到将处理它的HTTP进程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM