UNIX domain addressing for 4.2bsd IPC

Jim McKie jim at haring.UUCP
Sun Dec 11 12:07:44 AEST 1983


Here is a sample fragment of code which does the trick, the
IPC primer is wrong.

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

#define SOCKET	"NameOfSomeFile"
....
	struct sockaddr_un socket;
....
	socket.sun_family = AF_UNIX;
	sprintf(socket.sun_path, "%s", SOCKET);
	if((s = socket(AF_UNIX, SOCK_DGRAM, 0)) == -1){
		perror("program: socket");
		exit(1);
	}
	(void) unlink(socket.sun_path);
	if(bind(s, &socket, strlen(socket.sun_path)+2) == -1){
		perror("program: bind");
		exit(1);
	}
....

Jim McKie	Mathematisch Centrum, Amsterdam		....mcvax!jim



More information about the Comp.unix.wizards mailing list