2

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. 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)

John Saunders
  • 160,644
  • 26
  • 247
  • 397
Sandeep
  • 21
  • 3

1 Answers1

2

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.

user1055604
  • 1,624
  • 11
  • 28