python - Is there a difference between TCP and UNIX socket? -


for tcp socket, many client connect , send data , close. unix socket, if client close socket, server side close. it?

but in opinion, tcp has stop state....

this python unix socket code:

sock_file = "%s_%d.sock" % (sock_name, port) sock = socket.socket(socket.af_unix, socket.sock_stream) sock.bind(sock_file) sock.listen(1) 

taken serverfault (what's difference between unix socket , tcp/ip socket):

a unix socket inter-process communication mechanism allows bidirectional data exchange between processes running on same machine.

ip sockets (especially tcp/ip sockets) mechanism allowing communication between processes on network. in cases, can use tcp/ip sockets talk processes running on same computer (by using loopback interface).

unix domain sockets know they’re executing on same system, can avoid checks , operations (like routing); makes them faster , lighter ip sockets. if plan communicate processes on same host, better option ip sockets.

unix domain sockets subject file system permissions, while tcp sockets can controlled on packet filter level.


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -

recursion - Can every recursive algorithm be improved with dynamic programming? -