def __init__(self, addrString, role="server"): (family, addr) = pomp.parseAddr(addrString) self.pompCtx = pomp.Context(self) self.role = role if self.role == "server": self.pompCtx.listen(family, addr) elif self.role == "udp": self.pompCtx.bind(family, addr) else: self.pompCtx.connect(family, addr)
def main(): (options, args) = parseArgs() setupLog(options) app = App(options) # Get address if len(args) > 0: try: (app.sockFamily, app.sockAddr) = pomp.parseAddr(args[0]) except (ValueError, socket.error): sys.stderr.write("Failed to parse address: %s\n" % args[0]) sys.exit(1) args = args[1:] else: sys.stderr.write("Missing address\n") sys.exit(1) # Get message id (optional if dumping) if len(args) > 0: try: app.msgid = int(args[0]) app.hasmsg = True except ValueError: sys.stderr.write("Failed to parse message id: %s\n" % args[0]) sys.exit(1) args = args[1:] elif not options.dump: sys.stderr.write("Missing message id\n") sys.exit(1) # Get message format (optional) if len(args) > 0: app.msgfmt = args[0] args = args[1:] # Get message arguments (optional) if len(args) > 0: app.msgargs = args args = [] # Go ! app.run() sys.exit(0)
def __init__(self, address): super(SocketLedDriverClient, self).__init__() window = gtk.Window() window.set_title("Socket led driver client - evinrude") window.connect("destroy", self.on_window_destroy) pomp.looper.prepareLoop(self) self.ctx = pomp.Context(self) (self.sockFamily, self.sockAddr) = pomp.parseAddr(address) self.ctx.connect(self.sockFamily, self.sockAddr) self.label = gtk.Label() self.label.set_text("DISCONNECTED") self.event_box = gtk.EventBox() self.event_box.add(self.label) self.color = gtk.gdk.Color() self.event_box.modify_bg(gtk.STATE_NORMAL, self.color) window.add(self.event_box) window.resize(400, 400) window.show_all()
def start(self): (family, addr) = pomp.parseAddr(self.ctrlAddr) self.ctrlCtx.connect(family, addr) (family, addr) = pomp.parseAddr("inet:0.0.0.0:%u" % self.dataPort) self.dataCtx.bind(family, addr)