Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Is it possible for io-pkt to release (purge) open socket file descriptors?: (2 Items)
   
Is it possible for io-pkt to release (purge) open socket file descriptors?  
Hi I'm chasing an odd problem.

 

Here's a snippet of code:

 

    tempFD = socket( PacketFamily, SOCK_STREAM, 0 );

    setsockopt( tempFD, SOL_SOCKET, SO_REUSEADDR, (char *) &one,
sizeof(int));

    bindReturn = bind( tempFD,  (struct sockaddr *) &sock,
sizeof(sock));

 

 

   if ( listen( tempFD, backlog) == 0)

   {

       while( ! tc_is_shutdown() )

       {

          FD_ZERO( &readSet );

          FD_SET( tempFD, &readSet );

          timeout.tv_sec = 1;

          timeout.tv_usec = 0;

 

          result = select( tempFD + 1, &readSet, 0, 0, &timeout );

 

          if (result == -1)

          {

             break;

          }

          else if (result == 0)

          {

             if ( tc_is_shutdown() ) 

                 break;

             else 

                 continue;

          }

 

          if ( ! FD_ISSET( tempFD, &readSet ) ) 

              continue;

 

 

          ses_handle = accept( tempFD, ( struct sockaddr *)&sock, &len);

 

          if (setsockopt(ses_handle, SOL_SOCKET, SO_RCVTIMEO,
(char*)&tcptimeout, tcptimeoutLen) == -1)

          {

            perror("Set SO_RCVTIMEO: FAILED")

          }

 

          <more stuff here>

       }

   }

 

 

Well, I've had a failure report come my way which pretty much indicates
the following: the setsockopt() after the accept() returned a failure
which indicated that the File Descriptor was invalid.

 

 

Question:  under what circumstances would the io-pkt stack purge it's
current file descriptor list (if ever)?  

 

 

 

Maurice Gibbs

 

Software Designer

CommTest WaveReady BU

JDS Uniphase Corp.

613.843.2326

 

Re: Is it possible for io-pkt to release (purge) open socket file descriptors?  
On Wed, Aug 19, 2009 at 01:49:18PM -0400, maurice gibbs wrote:
> Hi I'm chasing an odd problem.
> 
>  
> 
> Here's a snippet of code:
> 
>  
> 
>     tempFD = socket( PacketFamily, SOCK_STREAM, 0 );
> 
>     setsockopt( tempFD, SOL_SOCKET, SO_REUSEADDR, (char *) &one,
> sizeof(int));
> 
>     bindReturn = bind( tempFD,  (struct sockaddr *) &sock,
> sizeof(sock));
> 
>  
> 
>  
> 
>    if ( listen( tempFD, backlog) == 0)
> 
>    {
> 
>        while( ! tc_is_shutdown() )
> 
>        {
> 
>           FD_ZERO( &readSet );
> 
>           FD_SET( tempFD, &readSet );
> 
>           timeout.tv_sec = 1;
> 
>           timeout.tv_usec = 0;
> 
>  
> 
>           result = select( tempFD + 1, &readSet, 0, 0, &timeout );
> 
>  
> 
>           if (result == -1)
> 
>           {
> 
>              break;
> 
>           }
> 
>           else if (result == 0)
> 
>           {
> 
>              if ( tc_is_shutdown() ) 
> 
>                  break;
> 
>              else 
> 
>                  continue;
> 
>           }
> 
>  
> 
>           if ( ! FD_ISSET( tempFD, &readSet ) ) 
> 
>               continue;
> 
>  
> 
>  
> 
>           ses_handle = accept( tempFD, ( struct sockaddr *)&sock, &len);
> 
>  
> 
>           if (setsockopt(ses_handle, SOL_SOCKET, SO_RCVTIMEO,
> (char*)&tcptimeout, tcptimeoutLen) == -1)
> 
>           {
> 
>             perror("Set SO_RCVTIMEO: FAILED")
> 
>           }
> 
>  
> 
>           <more stuff here>
> 
>        }
> 
>    }
> 
>  
> 
>  
> 
> Well, I've had a failure report come my way which pretty much indicates
> the following: the setsockopt() after the accept() returned a failure
> which indicated that the File Descriptor was invalid.
> 

It depends on the errno from setsockopt().  You should also
check the return from accept().

>  
> 
>  
> 
> Question:  under what circumstances would the io-pkt stack purge it's
> current file descriptor list (if ever)?  
> 

It should never do that.

Regards,

-seanb