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

int SHMClientSetupSession ( PDWORD  pdwClientID  ) 

Prepares a communication channel for the client to talk to the server.

This is called by the application to create a socket for local IPC with the server. The socket is associated to the file PCSCLITE_CSOCK_NAME.

Parameters:
[out] pdwClientID Client Connection ID.
Return values:
0 Success.
-1 Can not create the socket.
-1 The socket can not open a connection.
-1 Can not set the socket to non-blocking.

Definition at line 74 of file winscard_msg.c.

References SYS_CloseFile().

Referenced by SCardEstablishContextTH().

{
      struct sockaddr_un svc_addr;
      int one;

      if ((*pdwClientID = socket(AF_UNIX, SOCK_STREAM, 0)) < 0)
      {
            Log2(PCSC_LOG_CRITICAL, "Error: create on client socket: %s",
                  strerror(errno));
            return -1;
      }

      svc_addr.sun_family = AF_UNIX;
      strncpy(svc_addr.sun_path, PCSCLITE_CSOCK_NAME,
            sizeof(svc_addr.sun_path));

      if (connect(*pdwClientID, (struct sockaddr *) &svc_addr,
                  sizeof(svc_addr.sun_family) + strlen(svc_addr.sun_path) + 1) < 0)
      {
            Log2(PCSC_LOG_CRITICAL, "Error: connect to client socket: %s",
                  strerror(errno));
            SYS_CloseFile(*pdwClientID);
            return -1;
      }

      one = 1;
      if (ioctl(*pdwClientID, FIONBIO, &one) < 0)
      {
            Log2(PCSC_LOG_CRITICAL, "Error: cannot set socket nonblocking: %s",
                  strerror(errno));
            SYS_CloseFile(*pdwClientID);
            return -1;
      }

      return 0;
}


Generated by  Doxygen 1.6.0   Back to index