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.

699 questions
164
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
158
votes
5 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,941
  • 17
  • 58
  • 102
88
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,441
  • 2
  • 14
  • 18
75
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
  • 889
  • 2
  • 11
  • 16
51
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
  • 108,003
  • 19
  • 148
  • 163
45
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
  • 595
  • 1
  • 4
  • 7
44
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
  • 2,327
  • 2
  • 22
  • 30
42
votes
3 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
  • 523
  • 1
  • 4
  • 5
41
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
  • 69,737
  • 10
  • 105
  • 255
33
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
  • 13,882
  • 11
  • 56
  • 100
31
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
  • 728
  • 1
  • 9
  • 23
28
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,941
  • 17
  • 58
  • 102
24
votes
1 answer

Connect to a database over a unix socket using SQLAlchemy

I'm trying to connect to my Cloud SQL DB using SQLAlchemy from my cloud function but I can't seem to work out the correct connection string. DATABASE_URL=postgres://$DB_USER:$_DB_PWD@/$DB_NAME?unix_socket=/cloudsql/$DB_INSTANCE Which gives me the…
22
votes
6 answers

unix:///tmp/supervisor.sock no such file

Using Ubuntu 16.04 LTS to deploy my python app. Configured everything and the app is running manually. I want to automate it with supervisor, I have installed supervisor and configured it. But if I run: Supervisor config file: ; supervisor config…
Joseph Daudi
  • 1,557
  • 3
  • 17
  • 33
22
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
  • 5,449
  • 15
  • 46
  • 70
1
2 3
46 47