Questions tagged [unix-socket]

UNIX domain sockets are a technology for interprocess communication on a single computer.

UNIX domain sockets are a technology for interprocess communication on a single computer. They allow processes on the same machine to establish bidirectional connections to exchange either continuous byte streams or datagram messages.

The API is in many places the same as the one used for TCP/IP network sockets. A UNIX domain socket listening for connections may be represented as an inode in the file system, depending on the operating system and the parameters used to bind that socket.

Unix Domain Sockets can only communicate within a Linux OS kernel, they can not communicate externally to a kernel.

Details are provided in the unix(7) man page.

616 questions
134
votes
4 answers

TCP loopback connection vs Unix Domain Socket performance

Working on an Android and iOS based application which require communication with a server running in the same device. Currently using TCP loopback connection for communicating with App and Server (App written in user layer, server written in C++…
Rohit
  • 6,245
  • 14
  • 49
  • 96
133
votes
2 answers

unix domain socket VS named pipes?

After looking at a unix named socket and i thought they were named pipes. I looked at name pipes and didnt see much of a difference. I saw they were initialized differently but thats the only thing i notice. Both use the C write/read function and…
user34537
76
votes
1 answer

How do Unix Domain Sockets differentiate between multiple clients?

TCP has the tuple pairs (IP Addr/port/type) to tell one client from another. UDP passes the client IP and port. How does the unix domain keep track of different clients? In other words the server creates a socket bound to some path say…
Translucent Pain
  • 1,321
  • 2
  • 12
  • 18
59
votes
5 answers

htons() function in socket programing

I am new to socket programming and I am trying to understand the operation of htons(). I've read a few tutorials on the Internet like this and this one for instance. But I couldn't understand what htons() does exactly. I tried the following…
User123422
  • 729
  • 2
  • 10
  • 15
49
votes
8 answers

UNIX socket implementation for Java?

I realize that since UNIX sockets are platform-specific, there has to be some non-Java code involved. Specifically, we're interested in using JDBC to connect to a MySQL instance which only has UNIX domain sockets enabled. It doesn't look like…
Adam Bellaire
  • 99,441
  • 19
  • 144
  • 160
41
votes
7 answers

Unix Domain Socket: Using datagram communication between one server process and several client processes

I would like to establish an IPC connection between several processes on Linux. I have never used UNIX sockets before, and thus I don't know if this is the correct approach to this problem. One process receives data (unformated, binary) and shall…
BigMick
  • 433
  • 1
  • 4
  • 7
39
votes
2 answers

How to know whether any process is bound to a Unix domain socket?

I'm writing a Unix domain socket server for Linux. A peculiarity of Unix domain sockets I quickly found out is that, while creating a listening Unix socket creates the matching filesystem entry, closing the socket doesn't remove it. Moreover, until…
Simon Malinge
  • 493
  • 4
  • 5
38
votes
3 answers

Where to place Unix Domain (AF_UNIX) sockets' end points (files)?

Is there a convention where to place the 'files' representing the end points to Unix Domain Sockets? I tend to put them to /tmp/some-application-specific-subdir-name/, but I wonder if there is a more common place. The background is, that POSIX is…
alk
  • 66,653
  • 10
  • 83
  • 219
31
votes
1 answer

What are the differences from running PHP-FPM over an Unix Socket vs a TCP/IP Socket?

There are these two ways of running PHP-FPM. I know that nothing is bullet-proof in tech, but what are the pros and cons from both methods?
Leo Cavalcante
  • 1,887
  • 2
  • 19
  • 30
31
votes
3 answers

How to create Unix Domain Socket with a specific permissions in C?

I have a simple code, like: sockaddr_un address; address.sun_family = AF_UNIX; strcpy(address.sun_path, path); unlink(path); int fd = socket(AF_UNIX, SOCK_STREAM, 0); bind(fd, (sockaddr*)(&address), sizeof(address)); listen(fd, 100); I want to…
abyss.7
  • 12,136
  • 9
  • 44
  • 94
24
votes
2 answers

Can docker port forward to a unix file socket on the host container?

Running the following command fails: sudo docker run -p unix:///tmp/file.sock:44444 -d image_name Is something wrong with my port forwarding syntax or is a configuration like this not possible?
Ed Sullivan
  • 658
  • 1
  • 8
  • 22
24
votes
1 answer

HTTP over AF_UNIX: HTTP connection to unix socket

We have HTTP server , for which we have HTTP client based application (on Linux) working fine. But now we need to listen on Unix domain sockets from our client application. So is it possible to send/receive httprequest, httpresponse packet from…
Rohit
  • 6,245
  • 14
  • 49
  • 96
19
votes
5 answers

Where is php7.0-fpm.sock located

I have a simple project with directory structure I am setting up nginx config for my drupal site, and for the fastcgi_pass I have been using 127.0.0.1:9000 but I want to use a unix socket as suggested in this conf: # PHP 7 socket location. …
hidar
  • 3,939
  • 12
  • 36
  • 61
19
votes
5 answers

Gracefully shutdown UNIX-socket server on NodeJS running under Forever

I have an NodeJS application which sets up a UNIX-socket to expose some interprocess communication channel (some kind of monitoring stuff). UNIX-socket file is placed in os.tmpdir() folder (i.e. /tmp/app-monitor.sock). var net = require('net'); var…
Olegas
  • 9,749
  • 7
  • 46
  • 70
18
votes
2 answers

Identify other end of a unix domain socket connection

I'm trying to figure out what process is holding the other end of a unix domain socket. In some strace output I've identified a given file descriptor which is involved in the problem I'm currently debugging, and I'd like to know which process is on…
MvG
  • 51,562
  • 13
  • 126
  • 251
1
2 3
41 42