def pns_root (self, right): # set the L=R, bind a UDP port and move to "in-circle" state assert None == self.log ('root ip="%s"' % right[0], 'debug') self.pns_left = right[0] if self.socket == None: ip_peer.udp_bind ( self, self.pns_peer.pns_udp.addr[0] ) self.pns_in_circle (right)
def __init__ (self, pns_peer, ip): self.pns_peer = pns_peer self.pns_joined = {} self.pns_accepted = {} timeouts.Timeouts.__init__ (self, 3, 0.3) if ip_peer.udp_bind (self, ip, 3534): subscribed = pns_peer.pns_subscribed subscriptions = pns_peer.pns_subscriptions for name in subscribed.keys (): subscribed[name] = self.pns_subscribe ( name, subscriptions[name] )
def pns_join (self, left): assert None == self.log ('join ip="%s"' % left, 'debug') if self.socket == None: if not ip_peer.udp_bind ( self, self.pns_peer.pns_udp.addr[0] ): self.pns_left = None # failed to join return if self.sendto (self.PNS_SP, (left, 3534)) > 0: # joining now self.pns_statements[self.PNS_SP] = self.pns_left = left self.pns_peer.pns_udp.timeouts_push (( self.pns_name, self.PNS_SP )) else: self.pns_left = None # failed to join
def dns_connect (self): "bind the dispatcher to a UDP/IP socket" return ip_peer.udp_bind (self, self.dns_ip)
def dns_connect(self): "bind the dispatcher to a UDP/IP socket" return ip_peer.udp_bind(self, self.dns_ip)