0

I'm new to unix domain sockets so i tried beej's code for client and server from: http://beej.us/guide/bgipc/html/multi/unixsock.html

The server "works" but the client gives me an error when calling "connect" function. I'm getting: "Invalid argument" error.

any advice?

Sandburg
  • 757
  • 15
  • 28
user3206874
  • 795
  • 2
  • 7
  • 15

2 Answers2

0

try memset when you create a client socket

struct sockaddr_un sin;
memset(&sin, 0, sizeof(sin));
Dass
  • 326
  • 1
  • 11
0

I was actually having the same problem with that tutorial, the problem is in:

len = strlen(remote.sun_path) + sizeof(remote.sun_family);

That assignment is missing the null character at the end of sun_path, so you just have to add one to the expression on the right:

len = strlen(remote.sun_path) + sizeof(remote.sun_family) + 1;

In my case the call to connect succeeded with that change.