Пример #1
0
 def __init__(self, sock, keep_alive=True, base_cls=None):
     """Initialization defaults to SAPEnqueue as base class"""
     if base_cls is None:
         base_cls = SAPEnqueue
     SAPNIStreamSocket.__init__(self,
                                sock,
                                keep_alive=keep_alive,
                                base_cls=base_cls)
Пример #2
0
    def __init__(self,
                 sock,
                 route,
                 talk_mode=None,
                 router_version=None,
                 keep_alive=True,
                 base_cls=None):
        """Initialize the routed stream socket. It should receive a socket
        connected with the SAP Router, and a route to specify to it. After
        initialization and if the route is accepted all calls to send() and
        recv() would be made to the target host/service trough the SAP
        Router.

        :param sock: a socket connected to the SAP Router
        :type sock: C{socket}

        :param route: a route to specify to the SAP Router
        :type route: ``list`` of :class:`SAPRouterRouteHop`

        :param talk_mode: the talk mode to use when routing
        :type talk_mode: ``int``

        :param router_version: the router version to use for requesting the
            route. If no router version is provided, it will be obtained from
            the SAP Router by means of a control packet.
        :type router_version: ``int``

        :param keep_alive: if true, the socket will automatically respond to
            keep-alive request messages. Otherwise, the keep-alive messages
            are passed to the caller in :class:`recv` and :class:`sr` calls.
        :type keep_alive: ``bool``

        :param base_cls: the base class to use when receiving packets, it uses
            SAPNI as default if no class specified
        :type base_cls: :class:`Packet` class

        """
        self.routed = False
        self.talk_mode = talk_mode
        self.router_version = router_version
        # Connect to the SAP Router
        SAPNIStreamSocket.__init__(self,
                                   sock,
                                   keep_alive=keep_alive,
                                   base_cls=base_cls)
        # Now that we've a NIStreamSocket, retrieve the router version if
        # was not specified
        if self.router_version is None:
            self.router_version = get_router_version(self)
        self.route_to(route, talk_mode)
Пример #3
0
    def __init__(self, sock, route, talk_mode=None, router_version=None,
                 keep_alive=True, base_cls=None):
        """Initialize the routed stream socket. It should receive a socket
        connected with the SAP Router, and a route to specify to it. After
        initialization and if the route is accepted all calls to send() and
        recv() would be made to the target host/service trough the SAP
        Router.

        :param sock: a socket connected to the SAP Router
        :type sock: C{socket}

        :param route: a route to specify to the SAP Router
        :type route: ``list`` of :class:`SAPRouterRouteHop`

        :param talk_mode: the talk mode to use when routing
        :type talk_mode: ``int``

        :param router_version: the router version to use for requesting the
            route. If no router version is provided, it will be obtained from
            the SAP Router by means of a control packet.
        :type router_version: ``int``

        :param keep_alive: if true, the socket will automatically respond to
            keep-alive request messages. Otherwise, the keep-alive messages
            are passed to the caller in :class:`recv` and :class:`sr` calls.
        :type keep_alive: ``bool``

        :param base_cls: the base class to use when receiving packets, it uses
            SAPNI as default if no class specified
        :type base_cls: :class:`Packet` class

        """
        self.routed = False
        self.talk_mode = talk_mode
        self.router_version = router_version
        # Connect to the SAP Router
        SAPNIStreamSocket.__init__(self, sock, keep_alive=keep_alive,
                                   base_cls=base_cls)
        # Now that we've a NIStreamSocket, retrieve the router version if
        # was not specified
        if self.router_version is None:
            self.router_version = get_router_version(self)
        self.route_to(route, talk_mode)
Пример #4
0
 def __init__(self, sock, keep_alive=True, base_cls=None):
     """Initialization defaults to SAPEnqueue as base class"""
     if base_cls is None:
         base_cls = SAPEnqueue
     SAPNIStreamSocket.__init__(self, sock, keep_alive=keep_alive, base_cls=base_cls)