Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How are domain sockets similar to tcp sockets?


Asked by Bryce Sloan on Dec 12, 2021 FAQ



Unix domain socket. Like named pipes, Unix domain sockets support transmission of a reliable stream of bytes (SOCK_STREAM, compare to TCP ). In addition, they support ordered and reliable transmission of datagrams (SOCK_SEQPACKET, compare to SCTP ), or unordered and unreliable transmission of datagrams (SOCK_DGRAM, compare to UDP ).
In respect to this,
TCP/IP sockets are addressed by IP address and port number and are used for network communications whether on the internet or private networks. Unix domain sockets on the other hand are only for inter-process communication on the same physical host.
Also Know, One of the most interesting options is Unix Domain Sockets that combine the convenient API of sockets with the higher performance of the other single-host methods. This post demonstrates some basic examples of using Unix domain sockets with Go and explores some benchmarks comparing them to TCP loop-back sockets.
In this manner,
When the server and client benchmark programs run on the same box, both the TCP/IP loopback and unix domain sockets can be used. Depending on the platform, unix domain sockets can achieve around 50% more throughput than the TCP/IP loopback (on Linux for instance).
And,
The Unix domain socket facility is a standard component of POSIX operating systems. The API for Unix domain sockets is similar to that of an Internet socket, but rather than using an underlying network protocol, all communication occurs entirely within the operating system kernel.