Sctp In Ruby31 Jan 2007
SCTP (Stream Control Transmission Protocol) is an alternative to TCP that has been in development for several years and is starting to draw some attention to itself.
Next week work is sending me on a 3 day SCTP training course and I’ve been having a poke at some sample code so I don’t embarass myself when I get there. IBM has a good introduction with some C sample code that worked well enough on my linux 2.6.19 system.
Being the ruby fanboi that I am, I then wanted to try opening an SCTP socket from a ruby script. Without going into SCTP implementation details, there are 2 ways of working with SCTP sockets - via the standard unix socket API, or using libsctp. The libsctp method provides superior functionality, however there don’t seem to be any ruby bindings yet.
To run the scripts, execute them using two terminals on the same machine. Under linux you will need to have the SCTP kernel module loaded, under FreeBSD i’m not sure what’s required.
If you’re familiar with using TCP sockets in ruby, you’ll notice there’s almost no difference. All I’ve done is use Socket::IPPROTO_SCTP instead of 0 for the third argument to Socket.new.
From a feature point of view, these scripts aren’t particuarly better than using a TCP socket - to take full advantage of SCTP ruby will need libsctp bindings. Any volunteers?