View Antoni Milton's profile on LinkedIn

Wednesday, June 9, 2010

How to write / setup SCTP client server program in RHEL system?

Setup:

Before run any SCTP application, we need to install SCTP libs from

http://lksctp.sourceforge.net/

Using the below command, register the SCTP module into kernel.

#modprobe sctp

http://linux.about.com/od/commands/l/blcmdl8_modprob.htm


SCTP Application writing:-


SCTP client and server system call follow same as TCP. ( like socket,bind,listen and accept )

Creating SCTP socket

Sock = socket( AF_INET, SOCK_STREAM, IPPROTO_SCTP );

Before listen, we need to set the value for the no.of stream for the socket using setsockopt system call.

struct sctp_initmsg startupsctp;

startupsctp.sinit_num_ostreams = 3;

startupsctp.sinit_max_instreams = 3;

startupsctp.sinit_max_attempts = 4;

ret = setsockopt( listen_Socket, IPPROTO_SCTP, SCTP_INITMSG, & startupsctp, sizeof(startupsctp) );

Using sctp_sendmsg() and sctp_recvmsg() system calls , we can send/receive data over the SCTP socket.


Example code:-

Please refer : http://www.ibm.com/developerworks/linux/library/l-sctp/