I have heard that sockets are used for all sorts of streaming between applications to send and receive data.

I have always thought and even read from articles that aim to give a "general sense" that sockets are used to create connections over networks.

However recently I saw that sockets are also used for local streaming/connections between apps which are not over a network.

My question;

  • How are sockets used for connections/streaming NOT over a network between apps?
有帮助吗?

解决方案

If the applications are on the same machine then you can use the localhost or loopback address 127.0.0.1 as the IP address of the socket and any port number > 1024 in both applications and then they can communicate over this connection .

其他提示

Also, if you want to use the socket approach and on linux, AF_UNIX is better than inet socket as they avoid some level of inet specific tasks like routing/adding-removing ip and transport headers, etc

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top