SCTP Programmer's Guide
4 Migrating TCP Applications to SCTP
This chapter discusses the changes required to a migrate a TCP application to SCTP.
NOTE: TCP calls, such as bind(), listen(), accept(), connect(), send(),
recv(), sendto(), recvfrom(), senmsg(), recvmsg(), work in an SCTP stack
without incorporating any changes.
To migrate TCP applications to SCTP, you must modify the following:
• To migrate native TCP applications, such as FTP, TELNET, RLOGIN, HTTP, to SCTP,
modify the IPPROTO_TCP definition in the TCP socket call to IPPROTO_SCTP, as
follows:
socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
The IPPROTO_SCTP parameter is defined in the netinet/in.h header file.
NOTE: You need not explicitly mention the netinet/in.h header file in the
application, because this header file is already included in the TCP applications.
• To enable TCP applications to use the advanced features of SCTP, such as sending
and receiving ancillary information, and receiving event notifications, TCP
applications can use the sendmsg() and recvmsg() calls. However, applications
must define the _XOPEN_SOURCE_EXTENDED macro and the /usr/lib/libxnet
library while compiling the application, because only the X/OPEN style msghdr
structure supports the ancillary mechanism.
SCTP APIs provide applications with an alternate method to read and write
ancillary information, and receive event notifications, without using the msghdr
structure. The alternate method is to use the sctp_sendmsg() and
sctp_recvmsg() calls instead of using the sendmsg() and recvmsg() calls.
These applications need not be compiled using the /usr/lib/libxnet library.
You can compile these applications using the /usr/lib/libsctp library.
Following are the benefits of migrating TCP applications to SCTP:
• The TCP applications can avail all the advanced features of SCTP, such as
multi-streaming, multi-homing, and also avoid head-of-line blocking.
• An FTP application in a TCP stack uses two sockets to send and receive data. It
uses one socket for controlling the connection and the other socket for sending or
receiving data. However, in an SCTP stack, an FTP application can use only one
socket and use two streams within the same association to achieve the same
functionality as that of TCP.
• HTTP applications can use the multi-streaming feature, such as multiple queries
within the same page wherein queries can be sent in parallel.
73