2 #include <sys/socket.h>
12 fprintf(stderr
, "Usage: mksock [-s | -d] PATH\n");
16 int main(int argc
, char ** argv
)
18 struct sockaddr_un sun
;
20 int type
= SOCK_DGRAM
;
23 if(argc
== 1) invmal();
26 if(strcmp(argv
[1],"-s")==0) type
= SOCK_STREAM
;
27 else if(strcmp(argv
[1],"-d")==0) type
= SOCK_DGRAM
;
29 if(argc
== 2) invmal();
33 memset(&sun
, 0, sizeof(sun
));
34 sun
.sun_family
= AF_UNIX
;
35 snprintf(sun
.sun_path
, sizeof(sun
.sun_path
), "%s", sockname
);
37 sockfd
= socket(PF_UNIX
, type
, 0);
39 r
= bind(sockfd
, (struct sockaddr
*)&sun
, sizeof(sun
));
41 fprintf(stderr
, "mksock: error making %s: %s\n", sun
.sun_path
, strerror(errno
));