>  After removing the (socklen_t*) typecast...
> # pcc -o reveal -D_POSIX_SOURCE -D_BSD_EXTENSION reveal.c -lbsd
> # ./reveal
> ERRNO: 12
> socket accept: Invalid argument

The precise error I get as well.  Thank you for confirming.  I'd
forgotten that one of the reasons for doing this was to add
"socklen_t" to the typedefs.

Let me add a bit of diagnostic information.

The ERRNO 12 is way out, ENOMEM has nothing to do with this.

The error seems to stem from two connected problems: the actual site
of the error lies with an attempt to open("/net/tcp/27/listen",
O_RDWR) when the specific connection has not been announce()d (in Plan
9 terms).  The reason for the error is that the code in
/sys/src/ape/listen.c:/^listenproc guarded by the for(;;) gets as far
as the cfd = open(listen, O_RDWR); but never returns from there, it
seems literally to exit() at this point.  Once the code exits, I
presume it closes the descriptor which causes the later "open" to
fail.

We know that the parent code closes the actual "socket" (nfd =
dup(fd); ...  close(nfd);) as well as the unused end of the pipe
(close (pfd[1]);) and then returns to the caller and thence to the
caller of the listen() procedure.

The child process, which ought to supply the name of the network
control file (/net/tcp/27/ctl in this case) never gets to the stage
where it can put this information in the "listen" file because it
can't even open it successfully.

There's clearly an error here and the worst symptom I can identify is
that the "/net/tcp/27/listen" file cannot be opened and that the
failure is both silent and fatal.  Here I'm afraid I'm right out of my
depths.

++L

PS: all disclaimers apply, there are too many nooks and crannies here
for me to feel confident that what I'm seeing is in fact what is
happening.


Reply via email to