[Twisted-Python] Change A UDP based server to TCP based
Hi all, I found twisted have a module called SIP which implements parts of RFC3261, Session Initial Protocol. 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. But the idea of "cut and copy" is really annoying. What will you do in my situation? BTW, if you are going to write a protocol which supports both UDP and TCP, what is your design going to be like?
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: http://divmod.org/trac/browser/trunk/Sine 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 two.
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.
Hi, thanks for your useful information. But from the change log, the project sine has not been modified for a least 4 month. Have you tried it? Could it work now? On Thu, Oct 30, 2008 at 9:55 PM, Allen Short <washort@twistedmatrix.com> wrote:
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: http://divmod.org/trac/browser/trunk/Sine
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 two.
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.
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- 有一种人,不知道是因为DNA的变异还是前世的夙缘,总是无法安稳下来。他们的生命之流如同咆哮奔涌的大河,没有一刻能够停顿下来。在寂静无人的深夜里,无梦相扰的安睡中,心中也有猛兽会随时醒来,躁动不安,永无宁日。
participants (2)
-
Allen Short
-
Peter Cai