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
0
votes
2 answers

Determine if server is already listening on path to unix domain socket

On Node.js version 10+ Say we have a server listening on a path (unix domain sockets): const server = net.createServer(socket => { }); const p = path.resolve(process.env.HOME + '/unix.sock'); server.listen(p); is there a way to determine if some…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
1 answer

Unix Domain Sockets instead of host/port for TCP-type server

This is for all Node.js versions 6+ Say I have currently have a TCP server with multiple clients: const server = net.createServer(s => { }); server.listen(6000); and I connect to it with clients: const s1 =…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
0
votes
2 answers

transmission endpoint not connected

I'm trying to create a communication between two processes after a fork, thus between a father process and a son process. I'm trying to use sockets with PF_UNIX and AF_UNIX families, but when I try to send a message, the error "transmission endpoint…
Tom Riddle
  • 33
  • 5
0
votes
1 answer

Node.js memcached with unix socket /var/run/memcached/memcached.sock

Node.js don't connecting to memcached server by using unix socket /var/run/memcached/memcached.sock I'm using this example code to connect memcached server var Memcached = require('memcached'); var mem = new…
Temüjin
  • 15,371
  • 8
  • 35
  • 57
0
votes
0 answers

How to send muliptle lists of hex strings from af unix socket in python

I am trying to send multiple hex strings in a list from AF unix socket from binascii import unhexlify message = [b'8501012a1b0ff5ff',b'8501012a1b000ff'] mess1 = unhexlify(message) print(mess1)
srilalitha
  • 19
  • 1
0
votes
1 answer

Why is os.fchmod not working with a socket file descriptor?

I'm trying to use os.fchmod() as specified in this tutorial. However, when I pass in a file descriptor and a mode, I get back a vague "Invalid Argument" error. import socket import stat import os s = socket.socket(socket.AF_UNIX,…
Cat
  • 55
  • 8
0
votes
1 answer

Why does the accept() call uses an empty sockaddr structure?

I just got asked this question and couldn't answer it, I looked at how I've been coding it and was really confused. This is how I have been programming the accept() call in a server: struct sockaddr_in client; size=sizeof(client); if((…
davigzzz
  • 134
  • 1
  • 12
0
votes
1 answer

getsockname() without bind()

I'm trying to get the port number of the socket, without calling bind(). The code is as follows. #include #include #include int main() { int sock = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC, 0); struct…
pepero
  • 7,095
  • 7
  • 41
  • 72
0
votes
0 answers

Bind external command output to a socket?

I'm looking for a working example how connect standard output of spawned external command to a unix socket. So far, I put up following snippet. require 'socket' class XkbSocket def initialize @sock_cld, @sock_par = UNIXSocket.pair at_exit…
torimus
  • 29
  • 5
0
votes
1 answer

Cannot send commands to Docker unix socket via Python

I have a script that send signals to containers using nc (specifically the openbsd version that supports -U for Unix domain sockets): echo -e "POST /containers/$HAPROXY_CONTAINER/kill?signal=HUP HTTP/1.0\r\n" | \ nc -U /var/run/docker.sock I wanted…
djsumdog
  • 2,560
  • 1
  • 29
  • 55
0
votes
1 answer

Valid C code doesn't work in Swift project

I have code: #define SOCK_PATH "/Users/piotr/swigo.sock" int ux_server_socket() { const int fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd == -1) { printf("%s\n", strerror(errno)); return -1; } struct sockaddr_un…
PiotrPsz
  • 1
  • 1
0
votes
1 answer

How can I communicate with a unix socket using one connection in a bash script?

I want to read/write to a unix socket in a bash script, but only do it with one connection. All of the examples I've seen using nc say to open different socket connections for every read/write. Is there a way to do it using one connection throughout…
0
votes
1 answer

How to new a unix domain socket file with mode(777) in ruby

I create an unix domain socket file using this code: UNIXServer.new('tmp/my_socket.sock') It did create socket file but the default file mode is srwxrwxr-x, How can I specific the mode when creating, I found nothing about this problem in ruby doc.…
timlentse
  • 195
  • 2
  • 11
0
votes
2 answers

What sort of message does Snapd's API expect?

Snapd has documentation on a REST API. I'm able to connect to the socket from C# using the following var snapSocket = new Socket(AddressFamily.Unix, SocketType.Stream, ProtocolType.IP); var snapEndpoint = new…
M-Pixel
  • 3,501
  • 2
  • 16
  • 27
0
votes
0 answers

How to execute ksh script present on my linux box from a button present on web browser page

I have a small task which i want to give a GUI look and feel. There are many shell scripts (.sh & .ksh) present in my Linux machine, I want to execute them from Webpage. Eg: /user/###/##/diff.ksh present on my linux box. i want to execute it from…