SCTP Discussions

Text archives Help


Re: [SCTP-Discussion] UDP style problem


Chronological Thread 
  • From: Torbjörn Andersson <torbjorn.andersson AT kau.se>
  • To: <discussion AT sctp.de>
  • Subject: Re: [SCTP-Discussion] UDP style problem
  • Date: Fri Jun 14 17:47:04 2002
  • List-id: SCTP Discussions <discussion.sctp.de>

First I like to appologize for my errors in the first mail. I never use the
ext_send(...) function at any time.

The software I want to build is supposed to do this:

The client starts with an argument of the IP address of the server and port
number.
The client then starts with doing a connect to the server, using the
ext_connect(...) function.
The server accepts the new connection and starts sending back data on
several streams.
When the server is done it closes the connection using ext_close(...) and a
notification should then sent to the client when it has received all data.

Se my comments down below

I sent my source and beware that it contains lots of redundant code. Copy
and paste have been used..

Thank you for taking your time..

/MVH Torbjörn

ps -- Sweden will win the Fotball WC
----- Original Message -----
From: "Michael Tuexen"
<Michael.Tuexen AT micmac.franken.de>
To:
<discussion AT sctp.de>
Cc: "Torbjorn Andersson"
<tora AT tora-pc.cs.kau.se>
Sent: Thursday, June 13, 2002 10:52 PM
Subject: Re: [SCTP-Discussion] UDP style problem


> 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!

My fault... I'm not using ext_send as I have written.

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

The dataflow is from server to client, without any request done. Only
ext_connect(...) is used

> >
> > 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?

To be notified about the new connection ext_recvmsg must be used with the
socketoption recv-assoc_change notif jada jada turned on (
setsocketopt(..) )

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

It sends data fine but I cannot be received at the client.

> >
> > 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
>
> _______________________________________________
> discussion mailing list
> discussion AT sctp.de
> http://www.sctp.de/mailman/listinfo/discussion

Attachment: sctpClient.cc
Description: Binary data

Attachment: Makefile
Description: Binary data

Attachment: sctpServer.cc
Description: Binary data




Archive powered by MHonArc 2.6.19+.

Top of page