Logo Search packages:      
Sourcecode: pcsc-lite version File versions  Download package

INTERNAL int SHMProcessEventsServer ( PDWORD  pdwClientID,
int  blocktime 
)

Looks for messages sent by clients.

This is called by the Server's function SVCServiceRunLoop().

Parameters:
[out] pdwClientID Connection ID used to reference the Client.
[in] blocktime Timeout (not used).
Returns:
Error code.
Return values:
0 Success.
-1 Error accessing the communication channel.
-1 Can not set the connection to non-blocking mode.
2 Timeout.

Definition at line 168 of file winscard_msg_srv.c.

References commonSocket, and SHMProcessCommonChannelRequest().

Referenced by SVCServiceRunLoop().

{
      fd_set read_fd;
      int selret;
      struct timeval tv;
      
      tv.tv_sec = 1;
      tv.tv_usec = 0;

      FD_ZERO(&read_fd);

      /*
       * Set up the bit masks for select 
       */
      FD_SET(commonSocket, &read_fd);

      selret = select(commonSocket + 1, &read_fd, (fd_set *) NULL,
            (fd_set *) NULL, &tv);

      if (selret < 0)
      {
            if ((!AraKiri) && (!ReCheckSerialReaders))
                  Log2(PCSC_LOG_CRITICAL, "Select returns with failure: %s",
                        strerror(errno));
            return -1;
      }

      if (selret == 0)
            /* timeout */
            return 2;
      /*
       * A common pipe packet has arrived - it could be a new application  
       */
      if (FD_ISSET(commonSocket, &read_fd))
      {
            Log1(PCSC_LOG_DEBUG, "Common channel packet arrival");
            if (SHMProcessCommonChannelRequest(pdwClientID) == -1)
            {
                  Log2(PCSC_LOG_ERROR,
                        "error in SHMProcessCommonChannelRequest: %d", *pdwClientID);
                  return -1;
            } else
            {
                  Log2(PCSC_LOG_DEBUG,
                        "SHMProcessCommonChannelRequest detects: %d", *pdwClientID);
                  return 0;
            }
      }
      
      return -1;
}


Generated by  Doxygen 1.6.0   Back to index