unix-socket

Linux/Unix Socket Self-connection

↘锁芯ラ 提交于 2019-12-03 20:55:12
When a client try to connect to a server, if client and server are both localhost, self-connection may happen(source port and destination port happened to be the same.). But my problem is, client is not listening to that port, how can self-connection be possible? I found your question after encountering the same phenomenon. The best explanation I found is at Everything About Nothing: TCP Client Self Connect . You can ask for the port assigned to you via getsockname() and compare it to the remote port to detect these self connections: sockaddr_in addr_client; socklet_t len = sizeof(saddr_in);

Can not connect to Linux “abstract” unix socket

五迷三道 提交于 2019-12-03 09:30:25
问题 I'm trying to use UNIX sockets for inter-thread communication. The program is only intended to run on Linux. To avoid creating the socket files, I wanted to use "abstract" sockets, as documented in unix(7). However, I don't seem to be able to connect to these sockets. Everything works if I'm using "pathname" sockets, though. Here is the code (I haven't quoted any error handling, but it's done): thread#1: int log_socket = socket(AF_LOCAL, SOCK_STREAM, 0); struct sockaddr_un logaddr; socklen_t

PHP Artisan Migrate with MAMP and Unix Socket

一世执手 提交于 2019-12-02 19:45:51
I was developing my application originally in Laravel 4.2 but have since decided to move it to the 5.0 version so that it covers a lot more changes and strengths that 5.0 has over 4.2. I am trying to run my migratiosn however I am getting the error: [PDOException] SQLSTATE[HY000] [2002] No such file or directory I looked into this and noticed how it is because I'm running MAMP for my server instead of vagrant and homestead. I'm not knocking the uses of those two but I at this point feel more comfortable with MAMP until it fails me. The reason I know its MAMP is because of needing to declare

Read data directly from /dev/log Unix Domain Socket

泄露秘密 提交于 2019-12-02 11:26:29
My project aims at reading log messages directly from /dev/log UNIX domain socket in Java. Currently I am using junixsocket . Below is a sample code of client that reads from a unix socket. import java.io.File; import java.io.IOException; import java.io.InputStream; import org.newsclub.net.unix.AFUNIXSocket; import org.newsclub.net.unix.AFUNIXSocketAddress; import org.newsclub.net.unix.AFUNIXSocketException; public class SimpleTestClient { public static void main(String[] args) throws IOException { final File socketFile = new File("/dev/log"); AFUNIXSocket sock = AFUNIXSocket.newInstance();

Use Python xmlrpclib with unix domain sockets?

邮差的信 提交于 2019-11-30 18:56:53
I'm trying to interact with supervisord , and I'd like to talk with it over a unix socket (it's a shared hosting environment). What I've tried so far is: import xmlrpclib server = xmlrpclib.ServerProxy('unix:///path/to/supervisor.sock/RPC2') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/xmlrpclib.py", line 1549, in __init__ raise IOError, "unsupported XML-RPC protocol" IOError: unsupported XML-RPC protocol /path/to/supervisor.sock definitely exists. URIs of the form 'unix:///path/to/supervisor.sock/RPC2' are used by supervisord , which is

Read data directly from /dev/log Unix Domain Socket

偶尔善良 提交于 2019-11-30 09:54:05
问题 My project aims at reading log messages directly from /dev/log UNIX domain socket in Java. Currently I am using junixsocket. Below is a sample code of client that reads from a unix socket. import java.io.File; import java.io.IOException; import java.io.InputStream; import org.newsclub.net.unix.AFUNIXSocket; import org.newsclub.net.unix.AFUNIXSocketAddress; import org.newsclub.net.unix.AFUNIXSocketException; public class SimpleTestClient { public static void main(String[] args) throws

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

我只是一个虾纸丫 提交于 2019-11-30 08:19:24
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? Docker's -p syntax won't take a unix socket: -p=[] : Publish a container᾿s port to the host (format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort) One solution would be to: Run your container without any -p specification, we'll name it "cont1" ( --name cont1 ) Run a second container which: Bind mounts the unix socket ( -v /tmp/file.sock:/tmp/file.sock ) to have it accessible

Socket Programming: UDP Client-Server in C

我与影子孤独终老i 提交于 2019-11-30 07:24:31
I'm trying to write a client server program using UDP, and wait-and-stop, but I haven't got to that part, I'm still trying to figure it out how the two processes (server and client) communicate, because on my client program, the user needs to enter the server name or IP address, and a port name, and then send an expression that the server should calculate. However, I dug some tutorials in the internet and after coding accordingly (or I thought so) I can't make the client communicate with the server. Below is my code, please enlighten me what I'm doing wrong, if it's the bind() , sendto() ,

UNIX Domain Socket in Java

梦想与她 提交于 2019-11-30 06:44:13
I see these threads UNIX socket implementation for Java? and http://forums.sun.com/thread.jspa?threadID=713266 . The second link says that Java already supports UNIX Domain Socket. If that's true what class do I need to implement from Java?. From the first link, it says that Java does not support UNIX Domain Socket. If you need UNIX Domain Socket you must use a 3rd-party library. So, which is it? Java cannot create or access Unix Domain Sockets without using a 3rd party (native) library. The last comment on the second link above mentions this. The first link has some good (and correct)

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

半世苍凉 提交于 2019-11-30 06:14:23
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 atomically create the Unix Domain Socket file with a specific permissions, say: 0777 . The manual doesn't say anything about socket file permissions with regard to umask or whatever. Even, if the umask does affect the socket file, then it's not an atomic way - in multi-threaded program. I hope, there is a way to achieve my goal without using