Example #1
0
import socket
from coinpy.tools.reactor.reactor import Reactor, reactor
from coinpy.tools.reactor.asyncore_plugin import AsyncorePlugin

class EchoHandler(asyncore.dispatcher_with_send):
    def handle_read(self):
        data = self.recv(8192)
        if data:
            self.send(data)
            
class EchoServer(asyncore.dispatcher):
    def __init__(self, host, port):
        asyncore.dispatcher.__init__(self)
        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.set_reuse_addr()
        self.bind((host, port))
        self.listen(5)

    def handle_accept(self):
        pair = self.accept()
        if pair is None:
            pass
        else:
            sock, addr = pair
            print 'Incoming connection from %s' % repr(addr)
            handler = EchoHandler(sock)

server = EchoServer('localhost', 8080)
reactor.install(AsyncorePlugin())
reactor.run()    
Example #2
0
from coinpy.tools.reactor.reactor import Reactor, reactor
from coinpy.tools.reactor.wx_plugin import WxPlugin
import wx

reactor.install(WxPlugin())

frame = wx.Frame(None)
frame.Show()

reactor.run()    
Example #3
0
    def on_cancel(self, event):
        self.Show(False)
        self.future.set_error( (ActionCancelledException(), "cancelled"))
        self.passphrase_textctrl.SetValue("")
        
    def get_passphrase(self):
        reactor.call(self.open)
        self.future = Future()
        return self.future
        
    def set_passphrase(self, passphrase):
        return self.passphrase_textctrl.SetValue(passphrase)
            
    
if __name__ == '__main__':
    from coinpy.tools.reactor.reactor import reactor
    from coinpy.tools.reactor.wx_plugin import WxPlugin
    
    reactor.install(WxPlugin())
    
    @asynch_method
    def request_passphrase():
        f = yield EnterPassphraseView(None).get_passphrase()
        print "OK:", f
        reactor.stop()
    
    request_passphrase()
        

    reactor.run()
Example #4
0

class EchoHandler(asyncore.dispatcher_with_send):
    def handle_read(self):
        data = self.recv(8192)
        if data:
            self.send(data)


class EchoServer(asyncore.dispatcher):
    def __init__(self, host, port):
        asyncore.dispatcher.__init__(self)
        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.set_reuse_addr()
        self.bind((host, port))
        self.listen(5)

    def handle_accept(self):
        pair = self.accept()
        if pair is None:
            pass
        else:
            sock, addr = pair
            print 'Incoming connection from %s' % repr(addr)
            handler = EchoHandler(sock)


server = EchoServer('localhost', 8080)
reactor.install(AsyncorePlugin())
reactor.run()