12 /* socket extensions */
14 #include <sys/socket.h>
15 #include <netinet/in.h>
25 extern void _killmuxsid(void);
28 * replace the fd with a pipe and start a process to
29 * accept calls in. this is all to make select work.
32 listenproc(Rock *r, int fd)
34 char listen[Ctlsize], name[Ctlsize], *net, *p;
35 int cfd, nfd, dfd, pfd[2];
52 strcpy(listen, r->ctl);
53 p = strrchr(listen, '/');
56 strcpy(p+1, "listen");
61 /* replace fd with a pipe */
69 /* start listening process */
80 setpgid(getpid(), _muxsid);
81 while(_RENDEZVOUS(r, (void*)_muxsid) == (void*)~0)
85 while((v = _RENDEZVOUS(r, 0)) == (void*)~0)
94 /* for(fd = 0; fd < 30; fd++)
95 if(fd != nfd && fd != pfd[1])
99 cfd = open(listen, O_RDWR);
103 dfd = _sock_data(cfd, net, r->domain, r->stype, r->protocol, &nr);
107 if(write(pfd[1], nr->ctl, strlen(nr->ctl)) < 0)
109 if(read(pfd[1], name, sizeof(name)) <= 0)
126 struct sockaddr_un *lunix;
128 r = _sock_findrock(fd, 0);
137 cfd = open(r->ctl, O_RDWR);
142 port = _sock_inport(&r->addr);
144 if(write(cfd, "bind 0", 6) < 0) {
149 snprintf(msg, sizeof msg, "announce %d", port);
152 strcpy(msg, "announce *");
153 n = write(cfd, msg, strlen(msg));
155 errno = EOPNOTSUPP; /* Improve error reporting!!! */
161 return listenproc(r, fd);
167 lunix = (struct sockaddr_un*)&r->addr;
168 if(_sock_srv(lunix->sun_path, r->other) < 0){
175 errno = EAFNOSUPPORT;