forked from unpbook/unpv13e
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsctpclient01.c
35 lines (32 loc) · 934 Bytes
/
sctpclient01.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "unp.h"
int
main(int argc, char **argv)
{
int sock_fd;
struct sockaddr_in servaddr;
struct sctp_event_subscribe evnts;
int echo_to_all=0;
if(argc < 2)
err_quit("Missing host argument - use '%s host [echo]'\n",
argv[0]);
if(argc > 2) {
printf("Echoing messages to all streams\n");
echo_to_all = 1;
}
sock_fd = Socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP);
bzero(&servaddr, sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
servaddr.sin_port = htons(SERV_PORT);
Inet_pton(AF_INET, argv[1], &servaddr.sin_addr);
bzero(&evnts, sizeof(evnts));
evnts.sctp_data_io_event = 1;
Setsockopt(sock_fd,IPPROTO_SCTP, SCTP_EVENTS,
&evnts, sizeof(evnts));
if(echo_to_all == 0)
sctpstr_cli(stdin,sock_fd,(SA *)&servaddr,sizeof(servaddr));
else
sctpstr_cli_echoall(stdin,sock_fd,(SA *)&servaddr,sizeof(servaddr));
Close(sock_fd);
return(0);
}