コード例 #1
0
ファイル: slpd_outgoing.c プロジェクト: Distrotech/openslp
/** Handles outgoing requests pending on specified file discriptors.
 *
 * @param[in,out] fdcount - The number of file descriptors marked in fd_sets.
 * @param[in] readfds - The set of file descriptors with pending read IO.
 * @param[in] writefds - The set of file descriptors with pending write IO.
 */
void SLPDOutgoingHandler(int * fdcount, fd_set * readfds, fd_set * writefds)
{
   SLPDSocket * sock;
   sock = (SLPDSocket *) G_OutgoingSocketList.head;
   while (sock && *fdcount)
   {
      if (FD_ISSET(sock->fd, readfds))
      {
         switch (sock->state)
         {
            case DATAGRAM_MULTICAST:
            case DATAGRAM_BROADCAST:
            case DATAGRAM_UNICAST:
               OutgoingDatagramRead(&G_OutgoingSocketList, sock);
               break;

            case STREAM_READ:
            case STREAM_READ_FIRST:
               OutgoingStreamRead(&G_OutgoingSocketList, sock);
               break;

            default:
               /* No SOCKET_LISTEN sockets should exist */
               break;
         }

         *fdcount = *fdcount - 1;
      }
      else if (FD_ISSET(sock->fd, writefds))
      {
         switch (sock->state)
         {
            case STREAM_CONNECT_BLOCK:
               sock->age = 0;
               sock->state = STREAM_WRITE_FIRST;

            case STREAM_WRITE:
            case STREAM_WRITE_FIRST:
               OutgoingStreamWrite(&G_OutgoingSocketList, sock);
               break;

            default:
               break;
         }

         *fdcount = *fdcount - 1;
      }

      sock = (SLPDSocket *) sock->listitem.next;
   }
}
コード例 #2
0
/*=========================================================================*/
void SLPDOutgoingHandler(int* fdcount,
                         fd_set* readfds,
                         fd_set* writefds)

/* Handles all outgoing requests that are pending on the specified file    */
/* discriptors                                                             */
/*                                                                         */
/* fdcount  (IN/OUT) number of file descriptors marked in fd_sets          */
/*                                                                         */
/* readfds  (IN) file descriptors with pending read IO                     */
/*                                                                         */
/* writefds  (IN) file descriptors with pending read IO                    */
/*=========================================================================*/
{
    SLPDSocket* sock;
    sock = (SLPDSocket*)G_OutgoingSocketList.head;
    while ( sock && *fdcount )
    {
        if ( FD_ISSET(sock->fd,readfds) )
        {
            switch ( sock->state )
            {
            case DATAGRAM_MULTICAST:
            case DATAGRAM_BROADCAST:
            case DATAGRAM_UNICAST:
                OutgoingDatagramRead(&G_OutgoingSocketList,sock);
                break;

            case STREAM_READ:
            case STREAM_READ_FIRST:
                OutgoingStreamRead(&G_OutgoingSocketList,sock);
                break;

            default:
                /* No SOCKET_LISTEN sockets should exist */
                break;
            }

            *fdcount = *fdcount - 1;
        }
        else if ( FD_ISSET(sock->fd,writefds) )
        {
            switch ( sock->state )
            {
            
            case STREAM_CONNECT_BLOCK:
                sock->age = 0;
                sock->state = STREAM_WRITE_FIRST;

            case STREAM_WRITE:
            case STREAM_WRITE_FIRST:
                OutgoingStreamWrite(&G_OutgoingSocketList,sock);
                break;

            default:
                break;
            }

            *fdcount = *fdcount - 1;
        }

        sock = (SLPDSocket*)sock->listitem.next; 
    }                               
}