- if ((fd = socket(ga->a.ops->pf, SOCK_STREAM, 0)) < 0)
- error(sc, "couldn't create socket: %s", strerror(errno));
-
- /* --- Set it to allow address reuse --- */
-
- {
- int opt = 1;
- setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
- fdflags(fd, O_NONBLOCK, O_NONBLOCK, FD_CLOEXEC, FD_CLOEXEC);
- }
-
- /* --- Bind it to the right port --- */
-
- if (bind(fd, &ga->sa, ga->a.sz))
- error(sc, "couldn't bind to %s: %s", ss->s.desc, strerror(errno));
- if (ga->a.ops->bound)
- ga->a.ops->bound(&ga->a, ss->ao);
-
- /* --- Set it to listen for connections --- */