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)
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 _RENDEZVOUS(2, _muxsid);
85 _muxsid = _RENDEZVOUS(2, 0);
91 /* for(fd = 0; fd < 30; fd++)
92 if(fd != nfd && fd != pfd[1])
96 cfd = open(listen, O_RDWR);
100 dfd = _sock_data(cfd, net, r->domain, r->stype, r->protocol, &nr);
104 if(write(pfd[1], nr->ctl, strlen(nr->ctl)) < 0)
106 if(read(pfd[1], name, sizeof(name)) <= 0)
123 struct sockaddr_in *lip;
124 struct sockaddr_un *lunix;
126 r = _sock_findrock(fd, 0);
134 cfd = open(r->ctl, O_RDWR);
139 lip = (struct sockaddr_in*)&r->addr;
140 if(lip->sin_port >= 0) {
141 if(write(cfd, "bind 0", 6) < 0) {
146 snprintf(msg, sizeof msg, "announce %d",
147 ntohs(lip->sin_port));
150 strcpy(msg, "announce *");
151 n = write(cfd, msg, strlen(msg));
153 errno = EOPNOTSUPP; /* Improve error reporting!!! */
159 return listenproc(r, fd);
165 lunix = (struct sockaddr_un*)&r->addr;
166 if(_sock_srv(lunix->sun_path, r->other) < 0){
174 errno = EAFNOSUPPORT;