# Path: pysnmp/carrier/asynsock/base.py
# class AbstractSocketTransport(asyncore.dispatcher):
#     sockFamily = sockType = None
#     retryCount = 0; retryInterval = 0
#     def __init__(self, sock=None, sockMap=None):
#         if sock is None:
#             if self.sockFamily is None:
#                 raise error.CarrierError(
#                     'Address family %s not supported' % self.__class__.__name__
#                     )
#             if self.sockType is None:
#                 raise error.CarrierError(
#                     'Socket type %s not supported' % self.__class__.__name__
#                     )
#             try:
#                 sock = socket.socket(self.sockFamily, self.sockType)
#             except socket.error:
#                 raise error.CarrierError('socket() failed: %s' % sys.exc_info()[1])
#         if sockMap is None:
#             # The socket map is managed by the AsynsockDispatcher on
#             # which this transport is registered, so this is a fake
#             # socket map to avoid registering with deafult asyncore map.
#             sockMap = {}
#         asyncore.dispatcher.__init__(self, sock, sockMap)
# 
#     def registerSocket(self, sockMap=None):
#         self.add_channel(sockMap)
#         
#     def unregisterSocket(self, sockMap=None):
#         self.del_channel(sockMap)
#         
#     # Public API
#     
#     def openClientMode(self, iface=None):
#         raise error.CarrierError('Method not implemented')
# 
#     def openServerMode(self, iface=None):
#         raise error.CarrierError('Method not implemented')
#         
#     def sendMessage(self, outgoingMessage, transportAddress):
#         raise error.CarrierError('Method not implemented')
# 
#     def registerCbFun(self, cbFun):
#         self._cbFun = cbFun
# 
#     def unregisterCbFun(self):
#         self._cbFun = None
# 
#     def closeTransport(self):
#         self.unregisterCbFun()
#         self.close()
#         
#     # asyncore API
#     def handle_close(self): raise error.CarrierError(
#         'Transport unexpectedly closed'
#         )
#     def handle_error(self): raise
# 
# Path: pysnmp/debug.py
# class Debug:
#     def __init__(self, *flags):
#     def __str__(self):
#     def __call__(self, msg):
#     def __and__(self, flag):
#     def __rand__(self, flag):
# def setLogger(l):
# def hexdump(octets):


import socket, errno, sys
from pysnmp.carrier.asynsock.base import AbstractSocketTransport
from pysnmp.carrier import error
from pysnmp import debug
# Implements asyncore-based generic DGRAM transport

sockErrors = { # Ignore these socket errors
    errno.ESHUTDOWN: 1,
    errno.ENOTCONN: 1,
    errno.ECONNRESET: 0,
    errno.ECONNREFUSED: 0,
    errno.EAGAIN: 0,
    errno.EWOULDBLOCK: 0
    }
try:
    # bad FD may happen upon FD closure on n-1 select() event
    sockErrors[errno.EBADFD] = 1
except AttributeError:
    # Windows sockets do not have EBADFD
    pass


# Path: pysnmp/carrier/asynsock/base.py
# class AbstractSocketTransport(asyncore.dispatcher):
#     sockFamily = sockType = None
#     retryCount = 0; retryInterval = 0
#     def __init__(self, sock=None, sockMap=None):
#         if sock is None:
#             if self.sockFamily is None:
#                 raise error.CarrierError(
#                     'Address family %s not supported' % self.__class__.__name__
#                     )
#             if self.sockType is None:
#                 raise error.CarrierError(
#                     'Socket type %s not supported' % self.__class__.__name__
#                     )
#             try:
#                 sock = socket.socket(self.sockFamily, self.sockType)
#             except socket.error:
#                 raise error.CarrierError('socket() failed: %s' % sys.exc_info()[1])
#         if sockMap is None:
#             # The socket map is managed by the AsynsockDispatcher on
#             # which this transport is registered, so this is a fake
#             # socket map to avoid registering with deafult asyncore map.
#             sockMap = {}
#         asyncore.dispatcher.__init__(self, sock, sockMap)
# 
#     def registerSocket(self, sockMap=None):
#         self.add_channel(sockMap)
#         
#     def unregisterSocket(self, sockMap=None):
#         self.del_channel(sockMap)
#         
#     # Public API
#     
#     def openClientMode(self, iface=None):
#         raise error.CarrierError('Method not implemented')
# 
#     def openServerMode(self, iface=None):
#         raise error.CarrierError('Method not implemented')
#         
#     def sendMessage(self, outgoingMessage, transportAddress):
#         raise error.CarrierError('Method not implemented')
# 
#     def registerCbFun(self, cbFun):
#         self._cbFun = cbFun
# 
#     def unregisterCbFun(self):
#         self._cbFun = None
# 
#     def closeTransport(self):
#         self.unregisterCbFun()
#         self.close()
#         
#     # asyncore API
#     def handle_close(self): raise error.CarrierError(
#         'Transport unexpectedly closed'
#         )
#     def handle_error(self): raise
# 
# Path: pysnmp/debug.py
# class Debug:
#     def __init__(self, *flags):
#     def __str__(self):
#     def __call__(self, msg):
#     def __and__(self, flag):
#     def __rand__(self, flag):
# def setLogger(l):
# def hexdump(octets):


# Path: pysnmp/carrier/asynsock/dgram/base.py
import socket, errno, sys
from pysnmp.carrier.asynsock.base import AbstractSocketTransport
from pysnmp.carrier import error
from pysnmp import debug

# Implements asyncore-based generic DGRAM transport

sockErrors = { # Ignore these socket errors
    errno.ESHUTDOWN: 1,
    errno.ENOTCONN: 1,
    errno.ECONNRESET: 0,
    errno.ECONNREFUSED: 0,
    errno.EAGAIN: 0,
    errno.EWOULDBLOCK: 0
    }
try:
    # bad FD may happen upon FD closure on n-1 select() event
    sockErrors[errno.EBADFD] = 1
except AttributeError:
    # Windows sockets do not have EBADFD
    pass


class DgramSocketTransport(AbstractSocketTransport):