def connection_from_fd(self, fd): """Finds a connection from a file descriptor. Returns a Web100Connection object, or None. """ _c = libweb100.web100_connection_from_socket(self._agent, fd) if _c == None: return None cl = self.all_connections() for c in cl: if c._connection == _c: return c return None
try: if opts.verbose: gn=socket.getnameinfo(sa, 1) runlog("I", "Trying %s Port %s"%(gn[0], gn[1])) datasock = socket.socket(af, socktype, proto) except Exception, e: runlog("F", "Failed to create socket: %s"%(e)) sys.exit(2) try: datasock.connect(sa) except Exception, e: gn=socket.getnameinfo(sa, 1) runlog("F", "Failed to establish connection to %s on port %s, %s"%(gn[0], gn[1], e)) sys.exit(2) try: cvar.conn = libweb100.web100_connection_from_socket(ag, datasock.fileno()) except Exception, e: runlog("F", "Failed to get web100 conn %s"%(e)) sys.exit(2) if cvar.conn == 0: runlog("F", "Failed to find the connection %s"%(e)) sys.exit(2) try: cid = libweb100.web100_get_connection_cid(cvar.conn) except Exception, e: runlog("F", "Failed to find web100 cid %s"%(e)) sys.exit(2) ixmit = 1 elif (opts.cid <> -1): # -C cid # cid is already set # cid = opts.cid
runlog("I", "Trying %s Port %s" % (gn[0], gn[1])) datasock = socket.socket(af, socktype, proto) except Exception, e: runlog("F", "Failed to create socket: %s" % (e)) sys.exit(2) try: datasock.connect(sa) except Exception, e: gn = socket.getnameinfo(sa, 1) runlog( "F", "Failed to establish connection to %s on port %s, %s" % (gn[0], gn[1], e)) sys.exit(2) try: cvar.conn = libweb100.web100_connection_from_socket( ag, datasock.fileno()) except Exception, e: runlog("F", "Failed to get web100 conn %s" % (e)) sys.exit(2) if cvar.conn == 0: runlog("F", "Failed to find the connection %s" % (e)) sys.exit(2) try: cid = libweb100.web100_get_connection_cid(cvar.conn) except Exception, e: runlog("F", "Failed to find web100 cid %s" % (e)) sys.exit(2) ixmit = 1 elif (opts.cid <> -1): # -C cid # cid is already set # cid = opts.cid