# Path: pysnmp/carrier/asynsock/dispatch.py
# class AsynsockDispatcher(AbstractTransportDispatcher):
#     def __init__(self):
#         self.__sockMap = {} # use own map for MT safety
#         self.timeout = 0.5
#         AbstractTransportDispatcher.__init__(self)
# 
#     def getSocketMap(self): return self.__sockMap
#     def setSocketMap(self, sockMap=socket_map): self.__sockMap = sockMap
#     
#     def registerTransport(self, tDomain, t):
#         AbstractTransportDispatcher.registerTransport(self, tDomain, t)
#         t.registerSocket(self.__sockMap)
# 
#     def unregisterTransport(self, tDomain):
#         self.getTransport(tDomain).unregisterSocket(self.__sockMap)
#         AbstractTransportDispatcher.unregisterTransport(self, tDomain)
# 
#     def transportsAreWorking(self):
#         for transport in self.__sockMap.values():
#             if transport.writable():
#                 return 1
#         return 0
#     
#     def runDispatcher(self, timeout=0.0):
#         while self.jobsArePending() or self.transportsAreWorking():
#             poll(timeout and timeout or self.timeout, self.__sockMap)
#             self.handleTimerTick(time())
# 
# Path: pysnmp/carrier/asynsock/dgram/udp.py
# class UdpSocketTransport(DgramSocketTransport):
# 
# Path: pysnmp/carrier/asynsock/dgram/udp6.py
#     AF_INET6 = None
# class Udp6SocketTransport(DgramSocketTransport):
# 
# Path: pysnmp/carrier/asynsock/dgram/unix.py
#     AF_UNIX = None
# class UnixSocketTransport(DgramSocketTransport):
#     def openClientMode(self, iface=None):
#     def openServerMode(self, iface):
#     def closeTransport(self):


from pysnmp.carrier.asynsock.dispatch import AsynsockDispatcher
from pysnmp.carrier.asynsock.dgram import udp, udp6, unix
from pyasn1.codec.ber import encoder, decoder
from pysnmp.proto import api
import time, bisect
                    varBinds.append((oid, mibInstrIdx[oid](msgVer)))
                else:
                    # No such instance
                    varBinds.append((oid, val))
                    pendingErrors.append(
                        (pMod.apiPDU.setNoSuchInstanceError, errorIndex)
                        )
                    break
        else:
            # Report unsupported request type
            pMod.apiPDU.setErrorStatus(rspPDU, 'genErr')
        pMod.apiPDU.setVarBinds(rspPDU, varBinds)
        # Commit possible error indices to response PDU
        for f, i in pendingErrors:
            f(rspPDU, i)
        transportDispatcher.sendMessage(
            encoder.encode(rspMsg), transportDomain, transportAddress
            )
    return wholeMsg

transportDispatcher = AsynsockDispatcher()
transportDispatcher.registerRecvCbFun(cbFun)

# UDP/IPv4
transportDispatcher.registerTransport(
    udp.domainName, udp.UdpSocketTransport().openServerMode(('localhost', 161))
)

# UDP/IPv6
transportDispatcher.registerTransport(

# Path: pysnmp/carrier/asynsock/dispatch.py
# class AsynsockDispatcher(AbstractTransportDispatcher):
#     def __init__(self):
#         self.__sockMap = {} # use own map for MT safety
#         self.timeout = 0.5
#         AbstractTransportDispatcher.__init__(self)
# 
#     def getSocketMap(self): return self.__sockMap
#     def setSocketMap(self, sockMap=socket_map): self.__sockMap = sockMap
#     
#     def registerTransport(self, tDomain, t):
#         AbstractTransportDispatcher.registerTransport(self, tDomain, t)
#         t.registerSocket(self.__sockMap)
# 
#     def unregisterTransport(self, tDomain):
#         self.getTransport(tDomain).unregisterSocket(self.__sockMap)
#         AbstractTransportDispatcher.unregisterTransport(self, tDomain)
# 
#     def transportsAreWorking(self):
#         for transport in self.__sockMap.values():
#             if transport.writable():
#                 return 1
#         return 0
#     
#     def runDispatcher(self, timeout=0.0):
#         while self.jobsArePending() or self.transportsAreWorking():
#             poll(timeout and timeout or self.timeout, self.__sockMap)
#             self.handleTimerTick(time())
# 
# Path: pysnmp/carrier/asynsock/dgram/udp.py
# class UdpSocketTransport(DgramSocketTransport):
# 
# Path: pysnmp/carrier/asynsock/dgram/udp6.py
#     AF_INET6 = None
# class Udp6SocketTransport(DgramSocketTransport):
# 
# Path: pysnmp/carrier/asynsock/dgram/unix.py
#     AF_UNIX = None
# class UnixSocketTransport(DgramSocketTransport):
#     def openClientMode(self, iface=None):
#     def openServerMode(self, iface):
#     def closeTransport(self):


# Path: examples/v1arch/agent/cmdrsp.py
from pysnmp.carrier.asynsock.dispatch import AsynsockDispatcher
from pysnmp.carrier.asynsock.dgram import udp, udp6, unix
from pyasn1.codec.ber import encoder, decoder
from pysnmp.proto import api
import time, bisect

                    varBinds.append((oid, mibInstrIdx[oid](msgVer)))
                else:
                    # No such instance
                    varBinds.append((oid, val))
                    pendingErrors.append(
                        (pMod.apiPDU.setNoSuchInstanceError, errorIndex)
                        )
                    break
        else:
            # Report unsupported request type
            pMod.apiPDU.setErrorStatus(rspPDU, 'genErr')
        pMod.apiPDU.setVarBinds(rspPDU, varBinds)
        # Commit possible error indices to response PDU
        for f, i in pendingErrors:
            f(rspPDU, i)
        transportDispatcher.sendMessage(
            encoder.encode(rspMsg), transportDomain, transportAddress
            )
    return wholeMsg

transportDispatcher = AsynsockDispatcher()
transportDispatcher.registerRecvCbFun(cbFun)

# UDP/IPv4
transportDispatcher.registerTransport(
    udp.domainName, udp.UdpSocketTransport().openServerMode(('localhost', 161))
)

# UDP/IPv6
transportDispatcher.registerTransport(

    udp6.domainName, udp6.Udp6SocketTransport().openServerMode(('::1', 161))