I found a couple of answers, but they seem to be specifically relating to Windows machines. So my question is what are the differences between pipes and sockets, and when/how should you choose one over the other?
相关问题
- IPAddress.[Try]Parse parses 192.168 to 192.0.0.168
- What would prevent code running in a Docker contai
- How to run tcp and udp on a single port at same ti
- Docker-Compose: Can't Connect to Mongo
- Make Laravel Homestead Accessible via the Internet
相关文章
- Socket编程 TCP方式发送时间有点长
- RMI Threads prevent JVM from exiting after main()
- fsc.exe is very slow because it tries to access cr
- How many times will TCP retransmit
- boost:asio IPv4 address and UDP comms
- Writing an OS X kernel extension to implement Linu
- What's “tcp-backlog” in redis.conf
- Virtual Box limit Bandwith on network [closed]
To complete the answer given by Mike, it is important to mention the existence of UNIX domain sockets, which are available on any POSIX compliant operating system. Although very similar to "normal" internet sockets in terms of usage semantics, they are purely local to the machine (of course internet sockets can also work locally), and thus almost behave like a pipe. Almost, because a UNIX pipe is by definition unidirectional:
UNIX domain sockets also have a very unusual feature, as besides data, they also allow sending file descriptors: this way, an unprivileged process can access any file whose descriptor has been sent over the socket. This technique, according to Wikipedia, is used by the ClamAV antivirus scanning daemon.
Both pipes and sockets handle byte streams, but they do it in different ways...
Usage:
read()
andwrite()
to a pipe.BTW, you can use netcat or socat to join a socket to a pipe.