Twisted: UDP socket not closed.
- From: Kevac Marko <mkevac@xxxxxxxxx>
- Date: Sat, 22 Dec 2007 07:02:40 -0800 (PST)
Hi.
I have to send UDP packets very often. Approx twice in a second.
But socket is not closed after sending packet. So soon i bump into
open sockets\files limit.
How to close socket after sending data?
Python 2.5, Twisted
class DataClient(DatagramProtocol):
def __init__(self, address, datagram = "PONG"):
self.address, self.datagram = address, datagram
def startProtocol(self):
self.transport.socket.setsockopt(socket.SOL_SOCKET, \
socket.SO_BROADCAST, True)
self.transport.connect(self.address[0], self.address[1])
self.sendDatagram()
def sendDatagram(self):
self.transport.write(self.datagram)
debug("Data client: Sending to %s" % repr(self.address))
while True:
clientprotocol = DataClient(("255.255.255.255", 5999), data)
reactor.listenUDP(0, clientprotocol).stopListening()
knight@rknb:~$ ls -la /proc/15429/fd/ | wc -l
43
knight@rknb:~$ ls -la /proc/15429/fd/ | wc -l
44
knight@rknb:~$ ls -la /proc/15429/fd/ | wc -l
44
knight@rknb:~$ ls -la /proc/15429/fd/ | wc -l
44
knight@rknb:~$ ls -la /proc/15429/fd/ | wc -l
45
knight@rknb:~$ ls -la /proc/15429/fd/ | wc -l
45
knight@rknb:~$ ls -la /proc/15429/fd/ | wc -l
46
Thanks in advance.
.
- Prev by Date: gtk.TreeView cell inconsistent state
- Next by Date: Re: 3D plotting with python 2.5 on win32
- Previous by thread: gtk.TreeView cell inconsistent state
- Next by thread: doctest + sqlobject (TDD)
- Index(es):
Relevant Pages
|
Loading