[英]How to send message to a SCTP association which is found during receive?
I am having 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. 我获得每个连接的关联ID。 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) 我的问题是如何在关联ID上而不是在客户端地址上发送响应消息(例如sctp_sendmsg没有associaiton ID参数)
From http://linux.die.net/man/3/sctp_peeloff 来自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. sctp_peeloff
关闭现有关联的分支assoc_id
在一个一对多风格套接字sd
到一个单独的插座。 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. 例如,当应用程序希望让零星的消息发送者/接收者保留在原始的一对多样式套接字下,但将那些携带大量数据流量的关联分支到它们自己的单独套接字描述符中时,这是特别理想的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.