Re: Listen/Notify?

Manlio Perillo <[email protected]>
Newsgroups gmane.comp.python.db.pysqlite.user
Message-ID <[email protected]>
Manlio Perillo ha scritto:
> [...]
> However you can just define a function for sending a packet via UDP to 
> registered listeners.
> 
> As an example:
> 
> _listeners = set()
> _socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
> 
> def register_listener(host, port):
>      _listeners.add((host, int(port)))
> 
> def send_notify(name):
>      packet = struct.pack('!H', len(name)) + name
>      for host, port in _listeners:
>          _socket.sendto(packet, (host, port))

Sorry.
With UDP there is no need to send the packet length:
           _sockect.sendto(name, (host, port)

> 
> conn = sqlite.connect(':memory:')
> conn.create_function('register_listener', 2, register_listener)
> conn.create_function('send_notify', 1, send_notify)
> 
> 
> 

Regards   Manlio Perillo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.