def _socketCallback(self, cfSocket, callbackType,
                        ignoredAddress, ignoredData, context):
        """
        The socket callback issued by CFRunLoop.  This will issue C{doRead} or
        C{doWrite} calls to the L{IReadDescriptor} and L{IWriteDescriptor}
        registered with the file descriptor that we are being notified of.

        @param cfSocket: The L{CFSocket} which has got some activity.

        @param callbackType: The type of activity that we are being notified
            of.  Either L{kCFSocketReadCallBack} or L{kCFSocketWriteCallBack}.

        @param ignoredAddress: Unused, because this is not used for either of
            the callback types we register for.

        @param ignoredData: Unused, because this is not used for either of the
            callback types we register for.

        @param context: The data associated with this callback by
            L{CFSocketCreateWithNative} (in L{CFReactor._watchFD}).  A 2-tuple
            of C{(int, CFRunLoopSource)}.
        """
        (fd, smugglesrc) = context
        if fd not in self._fdmap:
            # Spurious notifications seem to be generated sometimes if you
            # CFSocketDisableCallBacks in the middle of an event.  I don't know
            # about this FD, any more, so let's get rid of it.
            CFRunLoopRemoveSource(
                self._cfrunloop, smugglesrc, kCFRunLoopCommonModes
            )
            return
        try:
            src, skt, readWriteDescriptor, rw = self._fdmap[fd]
            why = None
            isRead = callbackType == kCFSocketReadCallBack
            try:
                # CFSocket seems to deliver duplicate read/write notifications
                # sometimes, especially a duplicate writability notification
                # when first registering the socket.  This bears further
                # investigation, since I may have been mis-interpreting the
                # behavior I was seeing. (Running the full Twisted test suite,
                # while thorough, is not always entirely clear.) Until this has
                # been more thoroughly investigated , we consult our own
                # reading/writing state flags to determine whether we should
                # actually attempt a doRead/doWrite first.  -glyph
                if isRead:
                    if rw[_READ]:
                        why = readWriteDescriptor.doRead()
                else:
                    if rw[_WRITE]:
                        why = readWriteDescriptor.doWrite()
            except:
                why = sys.exc_info()[1]
                log.err()
            handfn = getattr(readWriteDescriptor, 'fileno', None)
            if handfn is None:
                why = _NO_FILENO
            elif handfn() == -1:
                why = _NO_FILEDESC
            if why:
                self._disconnectSelectable(readWriteDescriptor, why, isRead)
        except:
            log.err()
dataset/ETHPy150Open kuri65536/python-for-android/python-modules/twisted/twisted/internet/cfreactor.py/CFReactor._socketCallback/original