473,373 Members | 1,135 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,373 software developers and data experts.

Twisted: UDP socket not closed.

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.
Dec 22 '07 #1
0 1146

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Diez B. Roggisch | last post by:
Hi, I have a simple client-server app, that sits on a serial port and communicates through that with an attached microcontroller-board. To the outside, it exposes two sockets (file or inet)...
11
by: mir nazim | last post by:
hi, i m planning to start writing intranet applications and want ur real cool advices for choosing the correct platform. the choice is between the three: 1. Twisted 2. Medusa 3. Zope (i do...
1
by: Tim Gosselin | last post by:
I am writing a tcp tunnel but cannot find a way of detecting when a socket shuts down its read end without writing to the socket. For testing the write end of the remote endpoint I just do a: if...
4
by: DreJoh | last post by:
I've read many articles on the subject and the majority of them give the same solution that's in article 821625 on the MSDN website. I'm using the following code and when a the client disconnects...
1
by: Dr. J | last post by:
I have an application that opens a socket and connects to another application listening over a port. The problem I am encountering is that when the listening application is closed my application...
2
by: Droopy | last post by:
Hi, I try to implement a reusable socket class to send and receive data. It seems to work but I have 2 problems : 1) I rely on Socket.Available to detect that the connection is closed (no...
11
by: hazz | last post by:
smtpClient.Send(message) is causing me problems as per specifics in the trace below. Email is sent but not without this error typically upon sending the second email, but sometimes when running...
6
by: billiejoex | last post by:
Hi there. I'm setting up test suite for a project of mine. situations, if the socket is closed on the other end or not. I noticed that I can "detect" such state if a call to socket.read() returns...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.