SCTP Programmer's Guide

break;
printf ("Error, line must be of the form '[stream#]text'\n");
continue;
}
sri.sinfo_stream = strtol(buf+1, NULL, 0);
sz = strlen(buf);
len = sizeof(serv_addr);
sz = sctp_sendmsg (sock_fd, buf, sz, 0, len, 0, 0,
sri.sinfo_stream, 0, 0);
if (debug) printf ("sctp_sendmsg:[%d,e:%d]\n", sz, errno);
if (sz <= 0)
break;
sz = sctp_recvmsg (sock_fd, buf, sizeof(buf),
0, 0, &sri, &msg_flags);
if (debug) printf ("sctp_recvmsg:[%d,e:%d] ", sz, errno);
if (sz <= 0)
break;
printf ("<-- %s on str %d\n", buf, sri.sinfo_stream);
memset (buf, 0, sizeof(buf));
printf ("<S>: ");
}
printf ("\nOver !!\n");
close (sock_fd);
return 0;
}
One-to-Many Client Program
The following sample program is an implementation of an echo client over SCTP in a
one-to-one association:
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <unistd.h>
#include <netinet/sctp.h>
#include <sys/uio.h>
int debug=0;
int main(argc, argv)
int argc;
char **argv;
82 SCTP Sample Programs