SCTP Discussions

Text archives Help


[SCTP-Discussion] Regarding the crash submission.


Chronological Thread 
  • From: Torbjorn Andersson <tora AT tora-pc.cs.kau.se>
  • To: discussion AT sctp.de
  • Subject: [SCTP-Discussion] Regarding the crash submission.
  • Date: Mon Apr 8 11:57:01 2002
  • List-id: SCTP Discussions <discussion.sctp.de>

This is the recieving funktion that I use in my program. It's almost the same
as the funktion in sctpterminal in socket_program subdir, except i put in a
loop. Do you have any comments on this program ?

void receiveResponse(Socket *clientSocket)
{
char buffer[16384];
SocketMessage<CSpace(sizeof(sctp_sndrcvinfo))> message;
while(1) {
message.clear();
message.setBuffer((char*)buffer,sizeof(buffer));
// ====== Receive string from association =============================
const ssize_t dataLength = clientSocket->receiveMsg(&message.Header,0);
if(dataLength < 0) {
cleanUpAndExit(1);
}
else{
printControl(&message.Header);
unsigned short streamID = 0;
unsigned int protoID = 0;
cmsghdr* cmsg = message.getFirstHeader();
if(cmsg != NULL) {
while(cmsg != NULL) {
if((cmsg->cmsg_level == IPPROTO_SCTP) &&
(cmsg->cmsg_type == SCTP_SNDRCV)) {
sctp_sndrcvinfo* info = (sctp_sndrcvinfo*)CData(cmsg);
streamID = info->sinfo_stream;
protoID = info->sinfo_ppid;
}
cmsg = message.getNextHeader(cmsg);
}
}
if(message.Header.msg_flags & MSG_NOTIFICATION) {
sctp_notification* notification = (sctp_notification*)&buffer;
printNotification(notification);
}
else{
buffer[dataLength] = 0x00;
handleRecievedData(buffer,dataLength,streamID);
}
}
}
}

/thanks Torbjörn




Archive powered by MHonArc 2.6.19+.

Top of page