简体   繁体   English

如何将消息发送到接收期间找到的SCTP关联?

[英]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.

相关问题 如何通过消息队列发送和接收结构? - how to send and receive structs through message queues? 如何从另一个窗口/程序发送/接收消息? - How to send/receive a message from another window/program? 如何在异步boost :: asio处理程序中获取接收消息的端点? - How get endpoint, which receive message, in async boost::asio handler? 套接字服务器无法接收客户端发送的消息 - socket server could not receive the message send by client 是否有可能触发2个由1个send触发的接收回调? - Is it possible to fire 2 receive callback which is fired by 1 send? 如何中断被信号阻塞的增强消息队列发送和接收? - How can I interrupt boost message queue send & receive that are being blocked by signals? 如何在 OMNET++ 中从节点 A 向节点 B 发送消息,然后从节点 B 向节点 A 接收另一个消息? - How to send a message from node A to node B and then receive another msg from node B to node A in OMNET++? 绑定在同一端口上的两个进程如何接收相同的消息? - How can two processes which bind on the same port receive the same message? Boost :: message_queue ::接收/发送不适用于最新版本 - Boost::message_queue::receive/send not working with latest version 如何通过 libevent 接收所有消息 - how can I receive all message by libevent
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM