0

So, I have created a socket using C programming. I created the server inside /usr/src/server/pm as server.c in Minix3 VM and the client under /usr/Desktop as client.c in the host OS which is an Ubuntu machine. I'm facing the problem of selecting the sun_path name for both files in strcpy(name.sun_path, PATH). When I'm running both files in the host I just define a global variable, such as #define SOCK_PATH "socket" and use it as the second parameter in the strcpy function, and it works, but when I put the server in the minix VM the client throws an error saying that there's no such file or directory. What do I have to put in sun_path for client and for server?

Lewis Rodriguez
  • 23
  • 1
  • 2
  • 7
  • You put the path you want to create the socket at. – user253751 Mar 02 '16 at 03:53
  • Do they have to be exactly the same on both files? @immibis – Lewis Rodriguez Mar 02 '16 at 04:11
  • If they start with /, then yes. Otherwise, they're relative to the current directory, which might be different between the two programs. – user253751 Mar 02 '16 at 04:19
  • 1
    Also, as far as I know, *Unix sockets only ever work on the same computer*, and *a VM pretends to be a different computer*, so you cannot use them between VMs. (However, I'm not familiar with Minix, and maybe a Minix VM is something different to what I'm thinking of) – user253751 Mar 02 '16 at 04:19
  • @immibis is right. One cannot use unix domain sockets between VMs. You could use a daemon in each VM that communicate with each other using IP or some cross-VM protocol (some VM containers support special protocols between VMs), and act as an unix domain "bridge" between VMs, but that gets too complicated. Use an UDP socket instead. – Nominal Animal Mar 02 '16 at 06:13

0 Answers0