Frage

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?
War es hilfreich?

Lösung

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 .

Andere Tipps

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

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top