$ cat "

SCTP Socket Programming


If you are interested in socket programming you really should take a look at the Stream Control Transmission Protocol (SCTP). It is a new transport protocol that can be used in about the same way as both UDP and TCP, depending on which kind of SCTP socket that is used.

SCTP has two kinds of sockets, one-to-one sockets and one-to-many sockets. One-to-one sockets are very similar to classic TCP sockets, and are also known as TCP style sockets. One-to-many sockets are similar to UDP sockets, and as you probably can guess, are also known as UDP style sockets.

SCTP one-to-one sockets are actually so similar to TCP sockets that you can convert a TCP application to SCTP just by changing the socket call:

// TCP socket
int tcp_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

// SCTP one-to-one socket
int sctp_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);

If you want to dig deeper into SCTP I can recommend Unix Network Programming, 3rd ed. by Stevens, R. The book covers both basic and more advanced parts of SCTP, with useful examples. If you do some kind of socket programming, you should own a copy of this book, no matter what protocol you currently use. The only problem with the SCTP part of the book is that the specification has changed slightly since the book was printed, so I would recommend updated man pages as API reference. Personally I prefer the Sun Solaris man pages, which are available both as web pages and PDF.

For RFC:s, drafts and documents SCTP.org is the place to go.

Written by Erik Öjebo 2009-01-17 16:44