SCTP Discussions

Text archives Help


Re: [SCTP-Discussion] UDP style problem


Chronological Thread 
  • From: Michael Tuexen <Michael.Tuexen AT micmac.franken.de>
  • To: discussion AT sctp.de
  • Cc: Torbjorn Andersson <tora AT tora-pc.cs.kau.se>
  • Subject: Re: [SCTP-Discussion] UDP style problem
  • Date: Thu Jun 13 22:57:00 2002
  • List-id: SCTP Discussions <discussion.sctp.de>

Dear Torbjorn,

it would be helpful if you could paste the complete source code
in your mail. I will assume, that you have not omitted something
important.
That there is a SEGFAULT is a bug and I would like to get that
fixed. So please send me (and Thomas) the source code so that
we can fix that bug. But I think you are not using the socket API
correctly. See my comments below.

Best regards
Michael

On Thursday, June 13, 2002, at 03:47 PM, Torbjorn Andersson wrote:

Hello... I'm trying to recevie data on a UDP style socket...
This is the sequence of commands to SCTP I have tried.

1-------------- Server side ------------------------

fd = ext_socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP);

2-----------------------------------------------

struct sctp_initmsg initmsg;
initmsg.sinit_num_ostreams = 100;
initmsg.sinit_max_instreams = 1;
initmsg.sinit_max_attempts = 0;
initmsg.sinit_max_init_timeo = 60;

if (ext_setsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &initmsg,
sizeof(initmsg)) < 0) {
perror("setsockopt SCTP_INITMSG");
exit(1);
}

3------------------------------------------------

sin->sin_family = AF_INET;
sin->sin_port = htons(APP_PORT);
sin->sin_addr.s_addr = INADDR_ANY;

ext_bind(fd, (struct sockaddr *)sin, sizeof (*sin));

4-------------------------------------------------

ext_listen(fd, 1)

5--------------------------------------------------

buf = (char*)sctp_recvmsg(fd, msg, buf, &buflen, &nr);
//from idexample.c in socket_programs

Up to here everything should be OK.
upon a assoc_change notif the program continue and try to reply with data on
by using

6---------------------------------------------------
ext_send(fd,msg,0);
From the man page of send:
Send(), sendto(), and sendmsg() are used to transmit a message to another
socket. Send() may be used only when the socket is in a connected state,
while sendto() and sendmsg() may be used at any time.

Your socket is NOT connected. And

ssize_t
send(int s, const void *msg, size_t len, int flags);

ssize_t
sendmsg(int s, const struct msghdr *msg, int flags);

are different calls. send gets a buffer pointer msg which is simply
send whereas sendmsg gets a pointer to a msghdr structure. Your are
using send, the idexample uses sendmsg!

The message contain both the address of the peer, received with the
assoc_change, and dito assoc_id in the sndrcvinfo structure...

That is why you must use sendmsg.
------------------------------------------------------
------------------------------------------------------

1-------------- Client side ------------------------

fd = ext_socket(PF_INET, SOCK_SEQPACKET, IPPROTO_SCTP);

2-----------------------------------------------

struct sctp_initmsg initmsg;
initmsg.sinit_num_ostreams = 1;
initmsg.sinit_max_instreams = 100;
initmsg.sinit_max_attempts = 0;
initmsg.sinit_max_init_timeo = 60;

if (ext_setsockopt(fd, IPPROTO_SCTP, SCTP_INITMSG, &initmsg,
sizeof(initmsg)) < 0) {
perror("setsockopt SCTP_INITMSG");
exit(1);
}

3------------------------------------------------

sin->sin_family = AF_INET;
sin->sin_port = htons(APP_PORT);
sin->sin_addr.s_addr = INADDR_ANY;

ext_bind(fd, (struct sockaddr *)sin, sizeof (*sin));

4-------------------------------------------------

ext_connect(fd,(struct sockaddr*)sin,sizeof(struct sockaddr));
Why are you calling connect? This is not necessary. Simply call
sendto or sendmsg to send something. The association will be
established automatically.

5--------------------------------------------------

buf = (char*)sctp_recvmsg(fd, msg, buf, &buflen, &nr);
//from idexample.c in socket_programs

Hmm. Both your client and server are calling sctp_recv first. How
can this work?
--------------------------------------------------
--------------------------------------------------

On the client side the (5) ext_recvmsg() returns null and sometimes crashes.

are you talking about ext_recvmsg or sctp_recvmsg? Please post the source code.
The crash is a bug.
Not sure :( ...

I use ethereal to se what happens on the network and all the data is
transfered correctly...
I do not understand why your server can send anything, but ethereal is
the right tool to use.

Does anyone have any comments about this ?
Please post the source code such that we can debug the error handling of the
socketapi and/or can help you in debugging your code.

If you do not want to post your code on the list, send it to
Michael.Tuexen AT micmac.franken.de

/Torbjörn


_______________________________________________
discussion mailing list
discussion AT sctp.de
http://www.sctp.de/mailman/listinfo/discussion


Michael.Tuexen AT micmac.franken.de





Archive powered by MHonArc 2.6.19+.

Top of page