I am havin开发者_Go百科g an socket to receive data from multiple clients.
sockfd = socket(...);
bind(sockfd, ...);
listen(sockfd, ...);
while (true) {
nread = sctp_rcvmsg(sockfd, ..., buf, ..., &info);
assoc_id = sinfo.sinfo_assoc_id;
stream = sinfo.sinfo_stream;
handle_message(assoc_id, stream, buf, nread);
}
I get the association Id for each connection. My question is how can I send the response message on the association ID rather than using the client address(eg sctp_sendmsg doesnt have associaiton ID parameter)
From http://linux.die.net/man/3/sctp_peeloff
int sctp_peeloff(int sd, sctp_assoc_t assoc_id);
sctp_peeloff
branches off an existing association assoc_id
on a one-to-many style socket sd
into a separate socket. The new socket is a one-to-one style socket.
This is particularly desirable when, for instance, the application wishes to have a number of sporadic message senders/receivers remain under the original one-to-many style socket, but branch off those associations carrying high volume data traffic into their own separate socket descriptors.
精彩评论