[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

select/accept DECnet connection question ...



OK, here's the problem ... I set up a listening socket, which appears to
be working according to the returned status at the various stages, run
select() on the listening socket, and when select returns with FD_ISSET
on the read file descriptor due to an incoming connection request, I do
an accept() on the file descriptor, and it returns -1, with an errno of:

"Resource temporarily unavailable"

Any suggestions why this is happening? Have I missed any important
steps?
More detail below for those interested...

Thanks

Rob.

====================================================================
Here's the relevant lines of code in the right sequence 
(additional unrelated stuff removed and condensed for clarity) ...

On the server side:
 Set up listening socket:
   sockfd=socket(AF_DECnet,SOCK_SEQPACKET,DNPROTO_NSP);
   fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL, 0) | O_NONBLOCK);
   sockaddr.sdn_family   = AF_DECnet;
   sockaddr.sdn_flags    = 0x00;
   sockaddr.sdn_objnum   = 0x00;
   sockaddr.sdn_objnamel = strlen(objname);
   memcpy(sockaddr.sdn_objname,objname,strlen(objname));
   status = bind(sockfd, (struct sockaddr *)&sockaddr,
sizeof(sockaddr));
   status = listen(sockfd, MAX_OUTSTANDING_CONN);
 Wait for select() and do accept():
   FD_ZERO(&fds);
   FD_SET(sockfd, &fds);
   status = select(FD_SETSIZE, &fds, NULL, NULL, timeout);
   if ( (status > 0) && (FD_ISSET(sockfd, &fds)) )
      newsock=accept(sockfd, (struct sockaddr *)&sockaddr, &len);

Everything looks OK, up to the point of the accept() ... select returns
0 up to the point that I trigger the incoming connection from another
terminal window, at which point it returns 1, with the correct file
descriptor flag set. when I then try to accept() the incoming
connection, I get -1 returned, with errno = "Resource temporarily
unavailable"

On the client side:
   sockfd = socket(AF_DECnet, SOCK_SEQPACKET, DNPROTO_NSP);
   fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL, 0) | O_NONBLOCK);
   (set up sockaddr address)
   status = connect(sockfd, (struct sockaddr *)&sockaddr,
sizeof(sockaddr));
   if ((status < 0) && (errno == EINPROGRESS))
      FD_ZERO(&fds);
      FD_SET(sockfd, &fds);
      status = select(FD_SETSIZE, NULL, &fds, NULL, &timeout);
      if (status > 0)
         status=getsockopt(sockfd,SOL_SOCKET,SO_ERROR,&errval,&errsize);
         if (errval == 0)
            status = write(sockfd, msg_p, len);  

On the client side, the connect returns errno=EINPROGRESS (non-blocking
socket), so I wait for select() to return a write() flag set on the file
descriptor, and then getsockopt(SO_ERROR) to check it's ok to write (as
described in the man pages) ... it returns 0, indicating the client
thinks everything is now fine ....

Using client=1.2, server=1.5, then trace goes:
(I had to manually copy this from another screen, but if more data is
needed, then I can always run it again to a file ...)

1.2 > 1.5  conn-initiate 8293>0
1.5 > 1.2  conn-ack 8293
1.5 > 1.2  conn-confirm 14277>8293
1.2 > 1.5  link-service 8293>14277 ack 0 seg 1 dat seg count 0
1.2 > 1.5  link-service 8293>14277 ack 0 seg 1 dat seg count 0
1.2 > 1.5  link-service 8293>14277 ack 0 seg 1 dat seg count 0

and that's about as far as it gets .... I assume to get any further, it
needs for me to accept() the connection!

I am planning on using SO_CONDATA in the incoming connection (there's
none right now), and so I have a getsockopt(SO_CONDATA) call after the
accept() to get the CONDATA, if any ... is this the right place to put
it?
-----------------------------------------------------------------------------
To unsubscribe from this list, send a mail to majordomo@dreamtime.org
containing the line "unsubscribe linux-decnet"
-----------------------------------------------------------------------------