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

INTERNAL int ClientSetupSession ( uint32_t *  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.

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

Definition at line 90 of file winscard_msg.c.

Referenced by SCardCancel(), and SCardEstablishContextTH().

      struct sockaddr_un svc_addr;
      int one;
      int ret;
      char *socketName;

      ret = socket(PF_UNIX, SOCK_STREAM, 0);
      if (ret < 0)
            Log2(PCSC_LOG_CRITICAL, "Error: create on client socket: %s",
            return -1;
      *pdwClientID = ret;

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

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

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

      return 0;

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index