Python asyncore.socket_map() Examples
The following are 30
code examples of asyncore.socket_map().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
asyncore
, or try the search function
.
Example #1
Source File: test_asyncore.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 6 votes |
def closeall_check(self, usedefault): # Check that close_all() closes everything in a given map l = [] testmap = {} for i in range(10): c = dummychannel() l.append(c) self.assertEqual(c.socket.closed, False) testmap[i] = c if usedefault: socketmap = asyncore.socket_map try: asyncore.socket_map = testmap asyncore.close_all() finally: testmap, asyncore.socket_map = asyncore.socket_map, socketmap else: asyncore.close_all(testmap) self.assertEqual(len(testmap), 0) for c in l: self.assertEqual(c.socket.closed, True)
Example #2
Source File: smtpd.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) try: self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) self.listen(5) except: # cleanup asyncore.socket_map before raising self.close() raise else: print >> DEBUGSTREAM, \ '%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % ( self.__class__.__name__, time.ctime(time.time()), localaddr, remoteaddr)
Example #3
Source File: test_asyncore.py From oss-ftp with MIT License | 6 votes |
def closeall_check(self, usedefault): # Check that close_all() closes everything in a given map l = [] testmap = {} for i in range(10): c = dummychannel() l.append(c) self.assertEqual(c.socket.closed, False) testmap[i] = c if usedefault: socketmap = asyncore.socket_map try: asyncore.socket_map = testmap asyncore.close_all() finally: testmap, asyncore.socket_map = asyncore.socket_map, socketmap else: asyncore.close_all(testmap) self.assertEqual(len(testmap), 0) for c in l: self.assertEqual(c.socket.closed, True)
Example #4
Source File: smtpd.py From oss-ftp with MIT License | 6 votes |
def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) try: self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) self.listen(5) except: # cleanup asyncore.socket_map before raising self.close() raise else: print >> DEBUGSTREAM, \ '%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % ( self.__class__.__name__, time.ctime(time.time()), localaddr, remoteaddr)
Example #5
Source File: test_asyncore.py From BinderFilter with MIT License | 6 votes |
def closeall_check(self, usedefault): # Check that close_all() closes everything in a given map l = [] testmap = {} for i in range(10): c = dummychannel() l.append(c) self.assertEqual(c.socket.closed, False) testmap[i] = c if usedefault: socketmap = asyncore.socket_map try: asyncore.socket_map = testmap asyncore.close_all() finally: testmap, asyncore.socket_map = asyncore.socket_map, socketmap else: asyncore.close_all(testmap) self.assertEqual(len(testmap), 0) for c in l: self.assertEqual(c.socket.closed, True)
Example #6
Source File: smtpd.py From canape with GNU General Public License v3.0 | 6 votes |
def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) try: self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) self.listen(5) except: # cleanup asyncore.socket_map before raising self.close() raise else: print >> DEBUGSTREAM, \ '%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % ( self.__class__.__name__, time.ctime(time.time()), localaddr, remoteaddr)
Example #7
Source File: smtpd.py From BinderFilter with MIT License | 6 votes |
def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) try: self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) self.listen(5) except: # cleanup asyncore.socket_map before raising self.close() raise else: print >> DEBUGSTREAM, \ '%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % ( self.__class__.__name__, time.ctime(time.time()), localaddr, remoteaddr)
Example #8
Source File: test_asyncore.py From ironpython2 with Apache License 2.0 | 6 votes |
def closeall_check(self, usedefault): # Check that close_all() closes everything in a given map l = [] testmap = {} for i in range(10): c = dummychannel() l.append(c) self.assertEqual(c.socket.closed, False) testmap[i] = c if usedefault: socketmap = asyncore.socket_map try: asyncore.socket_map = testmap asyncore.close_all() finally: testmap, asyncore.socket_map = asyncore.socket_map, socketmap else: asyncore.close_all(testmap) self.assertEqual(len(testmap), 0) for c in l: self.assertEqual(c.socket.closed, True)
Example #9
Source File: test_asyncore.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def closeall_check(self, usedefault): # Check that close_all() closes everything in a given map l = [] testmap = {} for i in range(10): c = dummychannel() l.append(c) self.assertEqual(c.socket.closed, False) testmap[i] = c if usedefault: socketmap = asyncore.socket_map try: asyncore.socket_map = testmap asyncore.close_all() finally: testmap, asyncore.socket_map = asyncore.socket_map, socketmap else: asyncore.close_all(testmap) self.assertEqual(len(testmap), 0) for c in l: self.assertEqual(c.socket.closed, True)
Example #10
Source File: smtpd.py From meddle with MIT License | 6 votes |
def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) try: self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) self.listen(5) except: # cleanup asyncore.socket_map before raising self.close() raise else: print >> DEBUGSTREAM, \ '%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % ( self.__class__.__name__, time.ctime(time.time()), localaddr, remoteaddr)
Example #11
Source File: smtpd.py From ironpython2 with Apache License 2.0 | 6 votes |
def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) try: self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) self.listen(5) except: # cleanup asyncore.socket_map before raising self.close() raise else: print >> DEBUGSTREAM, \ '%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % ( self.__class__.__name__, time.ctime(time.time()), localaddr, remoteaddr)
Example #12
Source File: smtpd.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) try: self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) self.listen(5) except: # cleanup asyncore.socket_map before raising self.close() raise else: print >> DEBUGSTREAM, \ '%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % ( self.__class__.__name__, time.ctime(time.time()), localaddr, remoteaddr)
Example #13
Source File: rtl_mus.py From rtl_mus with GNU General Public License v3.0 | 6 votes |
def rtl_tcp_asyncore_reset(timeout): global rtl_tcp_core global rtl_tcp_resetting if rtl_tcp_resetting: return #print "rtl_tcp_asyncore_reset" rtl_tcp_resetting=True time.sleep(timeout) try: rtl_tcp_core.close() except: pass try: del rtl_tcp_core except: pass rtl_tcp_core=rtl_tcp_asyncore() #print asyncore.socket_map rtl_tcp_resetting=False
Example #14
Source File: ftpserver.py From script-languages with MIT License | 6 votes |
def _make_epasv(self, extmode=False): """Initialize a passive data channel with remote client which issued a PASV or EPSV command. If extmode argument is True we assume that client issued EPSV in which case extended passive mode will be used (see RFC-2428). """ # close establishing DTP instances, if any self._shutdown_connecting_dtp() # close established data connections, if any if self.data_channel is not None: self.data_channel.close() self.data_channel = None # make sure we are not hitting the max connections limit if self.server.max_cons: if len(asyncore.socket_map) >= self.server.max_cons: msg = "Too many connections. Can't open data channel." self.respond("425 %s" %msg) self.log(msg) return # open data channel self._dtp_acceptor = self.passive_dtp(self, extmode)
Example #15
Source File: smtpd.py From unity-python with MIT License | 6 votes |
def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) try: self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) self.listen(5) except: # cleanup asyncore.socket_map before raising self.close() raise else: print >> DEBUGSTREAM, \ '%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % ( self.__class__.__name__, time.ctime(time.time()), localaddr, remoteaddr)
Example #16
Source File: smtpd.py From Splunking-Crime with GNU Affero General Public License v3.0 | 6 votes |
def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) try: self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) self.listen(5) except: # cleanup asyncore.socket_map before raising self.close() raise else: print >> DEBUGSTREAM, \ '%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % ( self.__class__.__name__, time.ctime(time.time()), localaddr, remoteaddr)
Example #17
Source File: test_asyncore.py From gcblue with BSD 3-Clause "New" or "Revised" License | 6 votes |
def closeall_check(self, usedefault): # Check that close_all() closes everything in a given map l = [] testmap = {} for i in range(10): c = dummychannel() l.append(c) self.assertEqual(c.socket.closed, False) testmap[i] = c if usedefault: socketmap = asyncore.socket_map try: asyncore.socket_map = testmap asyncore.close_all() finally: testmap, asyncore.socket_map = asyncore.socket_map, socketmap else: asyncore.close_all(testmap) self.assertEqual(len(testmap), 0) for c in l: self.assertEqual(c.socket.closed, True)
Example #18
Source File: recipe-577808.py From code with MIT License | 6 votes |
def loop(timeout=0.001, use_poll=False, map=None, count=None): """Start asyncore and scheduler loop. Use this as replacement of the original asyncore.loop() function. """ if use_poll and hasattr(asyncore.select, 'poll'): poll_fun = asyncore.poll2 else: poll_fun = asyncore.poll if map is None: map = asyncore.socket_map if count is None: while (map or _tasks): poll_fun(timeout, map) _scheduler() else: while (map or _tasks) and count > 0: poll_fun(timeout, map) _scheduler() count -= 1
Example #19
Source File: smtpd.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) try: self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) self.listen(5) except: # cleanup asyncore.socket_map before raising self.close() raise else: print >> DEBUGSTREAM, \ '%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % ( self.__class__.__name__, time.ctime(time.time()), localaddr, remoteaddr)
Example #20
Source File: smtpd.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) try: self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) self.listen(5) except: # cleanup asyncore.socket_map before raising self.close() raise else: print >> DEBUGSTREAM, \ '%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % ( self.__class__.__name__, time.ctime(time.time()), localaddr, remoteaddr)
Example #21
Source File: test_asyncore.py From ironpython3 with Apache License 2.0 | 6 votes |
def closeall_check(self, usedefault): # Check that close_all() closes everything in a given map l = [] testmap = {} for i in range(10): c = dummychannel() l.append(c) self.assertEqual(c.socket.closed, False) testmap[i] = c if usedefault: socketmap = asyncore.socket_map try: asyncore.socket_map = testmap asyncore.close_all() finally: testmap, asyncore.socket_map = asyncore.socket_map, socketmap else: asyncore.close_all(testmap) self.assertEqual(len(testmap), 0) for c in l: self.assertEqual(c.socket.closed, True)
Example #22
Source File: test_asyncore.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def closeall_check(self, usedefault): # Check that close_all() closes everything in a given map l = [] testmap = {} for i in range(10): c = dummychannel() l.append(c) self.assertEqual(c.socket.closed, False) testmap[i] = c if usedefault: socketmap = asyncore.socket_map try: asyncore.socket_map = testmap asyncore.close_all() finally: testmap, asyncore.socket_map = asyncore.socket_map, socketmap else: asyncore.close_all(testmap) self.assertEqual(len(testmap), 0) for c in l: self.assertEqual(c.socket.closed, True)
Example #23
Source File: test_asyncore.py From Fluid-Designer with GNU General Public License v3.0 | 6 votes |
def closeall_check(self, usedefault): # Check that close_all() closes everything in a given map l = [] testmap = {} for i in range(10): c = dummychannel() l.append(c) self.assertEqual(c.socket.closed, False) testmap[i] = c if usedefault: socketmap = asyncore.socket_map try: asyncore.socket_map = testmap asyncore.close_all() finally: testmap, asyncore.socket_map = asyncore.socket_map, socketmap else: asyncore.close_all(testmap) self.assertEqual(len(testmap), 0) for c in l: self.assertEqual(c.socket.closed, True)
Example #24
Source File: smtpd.py From RevitBatchProcessor with GNU General Public License v3.0 | 6 votes |
def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) try: self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) self.listen(5) except: # cleanup asyncore.socket_map before raising self.close() raise else: print >> DEBUGSTREAM, \ '%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % ( self.__class__.__name__, time.ctime(time.time()), localaddr, remoteaddr)
Example #25
Source File: smtpd.py From PokemonGo-DesktopMap with MIT License | 6 votes |
def __init__(self, localaddr, remoteaddr): self._localaddr = localaddr self._remoteaddr = remoteaddr asyncore.dispatcher.__init__(self) try: self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) self.listen(5) except: # cleanup asyncore.socket_map before raising self.close() raise else: print >> DEBUGSTREAM, \ '%s started at %s\n\tLocal addr: %s\n\tRemote addr:%s' % ( self.__class__.__name__, time.ctime(time.time()), localaddr, remoteaddr)
Example #26
Source File: __init__.py From script-languages with MIT License | 6 votes |
def __init__(self, localaddr, map, debug=False, esmtp=True): self._localaddr = localaddr self._remoteaddr = None self.__smtpchannel = _SMTPChannel if esmtp else smtpd.SMTPChannel self.__debug = debug self.__messages = [] asyncore.dispatcher.__init__(self, map=map) try: self.create_socket(socket.AF_INET, socket.SOCK_STREAM) # try to re-use a server port if possible self.set_reuse_addr() self.bind(localaddr) self.listen(5) except: # cleanup asyncore.socket_map before raising self.close() raise
Example #27
Source File: test_sendfile.py From pysendfile with MIT License | 5 votes |
def stop(self): assert self.running self._active = False self.join() assert not asyncore.socket_map, asyncore.socket_map
Example #28
Source File: test_smtp_ssl.py From sync-engine with GNU Affero General Public License v3.0 | 5 votes |
def test_smtp_ssl_verification_bad_cert(db, bad_cert_smtp_server, example_draft, local_smtp_account, api_client, patched_smtp): api_client = new_api_client(db, local_smtp_account.namespace) while len(asyncore.socket_map) < 1: gevent.sleep(0) # let SMTP daemon start up r = api_client.post_data('/send', example_draft) assert r.status_code == 200
Example #29
Source File: test_sendfile.py From pysendfile with MIT License | 5 votes |
def run(self): self._active = True self.__flag.set() while self._active and asyncore.socket_map: self._active_lock.acquire() asyncore.loop(timeout=0.001, count=1) self._active_lock.release() asyncore.close_all()
Example #30
Source File: test_smtplib.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def debugging_server(serv, serv_evt, client_evt): serv_evt.set() try: if hasattr(select, 'poll'): poll_fun = asyncore.poll2 else: poll_fun = asyncore.poll n = 1000 while asyncore.socket_map and n > 0: poll_fun(0.01, asyncore.socket_map) # when the client conversation is finished, it will # set client_evt, and it's then ok to kill the server if client_evt.is_set(): serv.close() break n -= 1 except socket.timeout: pass finally: if not client_evt.is_set(): # allow some time for the client to read the result time.sleep(0.5) serv.close() asyncore.close_all() serv_evt.set()