Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6749057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:38:39+00:00 2026-05-26T12:38:39+00:00

I have a class that inherits from twisted.internet.protocol.DatagramProtocol class. In my startProtocol() implementation I

  • 0

I have a class that inherits from twisted.internet.protocol.DatagramProtocol class. In my startProtocol() implementation I call startWriting(), so that socket gets notified each time I can write to it without blocking. Two questions:

  1. Which method twisted will call once socket will become writable?
  2. How should I call startWriting() method, if it needs to be called on particular time-intervals to limit the outgoing UDP bandwidth to particular Datagrams/Second amount?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:38:40+00:00Added an answer on May 26, 2026 at 12:38 pm

    Oops. I think I may have answered your question in another thread and lead you to believe that UDP flow control support in Twisted is a little more robust than it actually is. Nevertheless, you can get what you need to do done…

    1. Which method will Twisted call once socket will become writable?

    Unfortunately, UDP protocols in Twisted do not get monitored for writability, on the premise that UDP can always fail and so it should never raise EWOULDBLOCK. (Except actually, it does sometimes, and this is a bug in Twisted which I just re-discovered while answering this question. This only happens if Twisted is sending UDP at faster than local wire speed, which requires a very fast application and a very slow network.)

    As a workaround, your application can simply catch EWOULDBLOCK. For any other protocol, this type of workaround might constitute a serious problem, but in the case of UDP you already have to be prepared to lose any outgoing packets, so you need an in-band control flow mechanism anyway.

    Helping us get that bug through the review process is always an option too.

    If you want to get really fancy, you can write your own alternative to udp.Port (by implementing IFileDescriptor yourself) rather than writing a UDP protocol, and override doRead and doWrite (which are called when the underlying socket is readable and writable respectively). This will give you perfect write-level flow control, but probably isn’t necessary since, again, UDP will just drop your packets sometimes, and on networks without the ability to properly process “ICMP source quench” messages (which dumb firewalls configured to block ICMP will just block), dropped packets are your only source of flow control information. I’m not saying that you shouldn’t fix this bug in Twisted for real, but this fact of life in the UDP world is the likely reason that nobody has bothered to do so yet.

    2. How should I call startWriting() method, if it needs to be called on particular time-intervals to limit the outgoing UDP bandwidth to particular Datagrams/Second amount?

    Due to the limitations described in part 1 of this answer, UDP transports do not have a useful startWriting method.

    However, startWriting/stopWriting isn’t really the right way to time-limit your outgoing UDP bandwidth anyway.

    Simply call self.transport.write(...) at the appropriate times, after scheduling said calls with via an appropriate scheduling mechanism. LoopingCall, for example, was designed to invoke UDP sends for RTP media streaming at the appropriate interval for transmitting a sound sample. But you can also just calculate your own delay and use callLater directly. In any case, you likely will need to keep around some kind of queue mechanism in the event that you need to do any re-transmissions of outgoing data queued for transport over UDP, so just pop

    If you need to do inbound flow-control, UDP transports still support that quite nicely, with stopReading and startReading.

    Hope this answer was helpful, and sorry if I previously mislead you about Twisted’s capabilities in this area!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a repository class that inherits from a generic implementation: public namespace RepositoryImplementation
I have GraphicView class that inherits from UIView. Its initWithFrame method is: @implementation GraphicsView
I have a class that inherits from Hash . When this class itself gets
I have a class that inherits from ObservableCollection(Of MyObject) and the MyObject class handles
I have a class that inherits from a base class (this contains a lot
I have a class that inherits from a generic dictionary as follows: Class myClass
I have a class that inherits from Page, called APage. public abstract class APage:
Example: I have an class that inherits from UIImageView. An object creates an instance
If we have a class that inherits from multiple interfaces, and the interfaces have
I have a class A and another class that inherits from it, B. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.