[Twisted-Python] SIP TCP support

Allen Short washort at twistedmatrix.com
Thu Oct 30 09:55:18 EDT 2008

On Thu, Oct 30, 2008 at 09:17:07PM +0800, Peter Cai wrote:
> Hi all,
> I found twisted have a module called SIP which implements parts of
> RFC3261, Session Initial Protocol.

Most of the SIP code in Twisted is based on the obsolete RFC 2543. A
more compliant version has been developed here:

At some point this code will be moved into Twisted.

> As I am going to write an experimental SIP server, this module seems
> to be very useful for me.
> But, one problem : it's based on UDP.
> I skimmed the code and I think maybe I can "Cut and Copy" some code of
> this module to implement my own TCP SIP server.

It's more complicated than that -- the protocol behaviour for SIP is
different when transported over TCP instead of UDP. (See section
10.5.2 in RFC 3261.) But much of the code can be shared between the
> But the idea of "cut and copy" is really annoying.
> What will you do in my situation?

Contribute to Sine -- sine.sip.SIPTransport inherits from
DatagramProtocol and so is UDP-only at the moment. Ideally, most of
its behaviour could move to a mixin that a TCP SIP transport class
could inherit from as well.
> BTW, if you are going to write a protocol which supports both UDP and TCP,
> what is your design going to be like?

As I described above, write a protocol class for UDP and for TCP that
inherits from a common mixin class.

More information about the Twisted-Python mailing list