Greetings,

I would expect the following sample program to finish without errors, but instead the second assert is triggered
when running in DragonFlyBSD 4.2.3


  #include <stdio.h>
  #include <stdlib.h>
  #include <assert.h>

  #include <sys/types.h>
  #include <sys/socket.h>

  int main(int argc, char** argv)
  {
      struct sockaddr sa;
      socklen_t len;
      int type;
      int fds[2];

      if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds)) {
          printf("socketpair error");
          return 1;
      }

      if (getsockopt(fds[0], SOL_SOCKET, SO_TYPE, &type, &len)) {
          printf("getsockopt error\n");
          return 1;
      }

      len = sizeof(sa);
      if (getsockname(fds[0], &sa, &len)) {
          printf("getsockname error\n");
          return 1;
      }
      assert( type == SOCK_STREAM );
      assert( sa.sa_family == AF_UNIX );
  }

Instead of AF_UNIX the call to getsockname returns AF_UNSET.
Am I missing something ?

Thanks,
Marco





Reply via email to