Ho ridotto un po' la tua funzione, prova così solo per capire se almeno questo ti funziona...
codice:
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
int main()
{
struct sockaddr_un sad;
int mySocket;
mySocket = socket(AF_UNIX, SOCK_STREAM, 0);
if (mySocket < 0)
return 1;
memset(&sad,0, sizeof (struct sockaddr_un));
sad.sun_family = AF_UNIX;
strcpy(sad.sun_path, "/tmp/miosocket");
if (bind(mySocket, (struct sockaddr *) &sad, sizeof(sad)) < 0) {
perror("errore bind");
return 1;
} else
printf("bind ok\n");
return 0;
}