unix-socket

Getting “Address already in use” error using Unix socket

一笑奈何 提交于 2019-12-13 12:03:55
问题 Writing the C source below using Unix local sockets I got an error about the address already in use. After having checked man 7 Unix for further informations I tried to create a sub-folder where executing my program (obviously modifying the sun_path field on the current folder) but the error was ever the same. Is there someone able to help me? Source code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/socket.h> #include <sys/types.h> #include <sys/un.h> #include

Just get one last value from socket

社会主义新天地 提交于 2019-12-13 05:24:32
问题 I send data to socket on one side every second, but I can read that data on another side in any moment. Here's the writer: from settings import Config filename = Config.NAVIGATION_SOCKET_FILE client = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) client.settimeout(None) while True: try: client.connect(filename) break except Exception: continue messages = ["$GPRMC,125504.049,A,5542.2389,N,03741.6063,E,0.06,25.82,200906,,,*17", "$GPRMC,155604.049,A,5542.2389,N,03741.6063,E,0.06,25.82,200906,

kill socket.accept() call on closed unix socket

…衆ロ難τιáo~ 提交于 2019-12-12 06:18:31
问题 Socket.close() does not stop any blocking socket.accept() calls that are already running on that socket. I have several threads in my python program that only run a blocking socket.accept() call on a unix domain socket that has been closed already. I want to kill these threads by making the socket.accept() calls stop or raise an exception. I am trying to do this by loading new code in the program, without stopping the program. Therefore, changing the code that spawned these threads or that

Communicating between C and NodeJS using node-ipc and unix sockets

徘徊边缘 提交于 2019-12-11 16:49:10
问题 This question follows on from the following: Communicating between NodeJS and C using node-ipc and unix sockets In regards to the accepted solution (https://stackoverflow.com/a/39848936/1834057), I was wondering if someone might be able to clarify exactly how to send data from C to Node.js . The solution demonstrates sending data from Node.js to C , but not in reverse. I have an application that requires two-way communications, so the missing component is critical for me. My understanding of

WebSocket over AF_UNIX socket

你离开我真会死。 提交于 2019-12-11 13:52:39
问题 Is it possible to use WebSocket over AF_UNIX sockets (Unix-domain sockets)? Is it technically possible, and if so, do any implementations (mainly browser runtimes) support it? 回答1: Yes, this is possible. AutobahnPython supports running WebSocket over any stream-based transport supported by Twisted like: TCP TLS Unix Domain Socket Pipes Serial Please see here. FWIW, it also supports tunneling any stream-based protocol over WebSocket. E.g. it allows you to run SSH over WebSocket (over any

Replicate Curl unix-socket command in Java

旧时模样 提交于 2019-12-11 10:46:16
问题 I want to get the same string standard outputted by curl when I type something like: curl --unix-socket file.sock http://path/to/rest/request In my Java code. I figured out I need to use AFUNIXSocket, but I can set just the socket file on connection, so I suppose I have to manage my http connection manually. Is there a way to make it easier? How do I start an http connection through the socket I create? 回答1: So, I tried to manage the http connection by myself, it works but Im still looking

php (or python) listen to unix domain stream socket

一世执手 提交于 2019-12-11 10:23:30
问题 I need to create a script that listens to a unix socket and forward the incoming stream to a bot. The scripts are unable to connect. The issues seems to be related to the order of things. Proof of case I have created a socket and I am able to write to it. In session 1, I create a listener connection nc -lU /tmp/tg.sck In session 2, I write to the socket. while true; do echo "hello"; sleep 2; done | nc -U /tmp/tg.sck The above only works if I do it in that order. ==> Writing before you have a

Can not connect to an abstract unix socket in python

萝らか妹 提交于 2019-12-10 14:27:39
问题 I have a server written in c++ which creates and binds to an abstract unix socket with a namespace address of "\0hidden" . I also have a client which is written in c++ also and this client can successfully connect to my server. BTW, I do not have the source code of this client. Now I am trying to connect to my server using a client I have written in python with no success. I do not understand why my python client is not working. I am posting the relevant parts of my server and client codes.

Unix C socket server not accepting connections

妖精的绣舞 提交于 2019-12-10 10:17:49
问题 Here's the deal, I'm writing a simple tcp socket server in C (with unix system calls) that I'm not able to get to accept connections. From what I can tell, I get through the server initialization just fine, but when I try to connect to the port that I print out (see code below) it refuses as if nothing is there. More to the point, when I netstat that port isn't even in use. I'm not throwing any errors with my current set up, I'm all dried up for ideas. int main(){ int sock_fd; int conn_fd;

LocalSocket communication with Unix Domain in Android NDK

天涯浪子 提交于 2019-12-08 15:55:55
问题 I have Android application, which needs to establish unix domain socket connection with our C++ library (using Android NDK) public static String SOCKET_ADDRESS = "your.local.socket.address"; // STRING There is LocalSocket in java which accepts "string" (your.local.socket.address) #define ADDRESS "/tmp/unix.str" /* ABSOLUTE PATH */ struct sockaddr_un saun, fsaun; if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { perror("server: socket"); exit(1); } saun.sun_family = AF_UNIX; strcpy(saun.sun