6. network_listeners — Network listening facilities

python-brisa provides a network listening module which will make it easy to implement, for example, a udp server.

6.1. Implementing a simple udp server.

Look how simple it’s to implement a udp server

from brisa.core.reactors import install_default_reactor
reactor = install_default_reactor()

from brisa.core.network_listeners import UDPListeners

def forward_data(data, addr=''):
    # This is the data handler function, in this example it will simply
    # print the received data and the address from where it came
    print data, 'from ', addr

server = UDPListener('',
                     data_callback = foward_data)

# Be sure to register the UDPListener's stop function before using the
# start method, or the program doesn't end.

This is all it takes to implement a simple udp server

Table Of Contents

Previous topic

5. network — Network facilities

Next topic

7. webserver — Webserver facilities

This Page