SCTP Discussions

Text archives Help


Re: [SCTP-Discussion] setsockopt() returning invalid argument


Chronological Thread 
  • From: Michael Tuexen <Michael.Tuexen AT micmac.franken.de>
  • To: nitin rakh <nitinrakh AT gmail.com>
  • Cc: sctp-discussion AT sctp.de
  • Subject: Re: [SCTP-Discussion] setsockopt() returning invalid argument
  • Date: Mon, 9 Mar 2009 18:38:36 +0100
  • List-archive: <http://lists.franken.de/pipermail/sctp-discussion>
  • List-id: SCTP Discussions <sctp-discussion.sctp.de>

Hi,

I tested the program on the SCTP kernel implementation of Mac OS X. It runs fine.
So it must be an issue with the centOS. Since this mailing list is about
the scptlib userland implementation, I can not help you. Please contact
the support guys for centOS...

Best regards
Michael

On Mar 9, 2009, at 5:08 PM, nitin rakh wrote:


hi all,

i am use cent5 64bit os.

The problem when calling setsockopt it return error errno:22 Invalid argument

plz help me
example form ibm webside

/*
server
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <netinet/sctp.h>
#include "common.h"

int main()
{
int listenSock, connSock, ret;
struct sockaddr_in servaddr;
struct sctp_initmsg initmsg;
char buffer[MAX_BUFFER+1];
time_t currentTime;

/* Create SCTP TCP-Style Socket */
listenSock = socket( AF_INET, SOCK_STREAM, IPPROTO_SCTP );

/* Accept connections from any interface */
bzero( (void *)&servaddr, sizeof(servaddr) );
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl( INADDR_ANY );
servaddr.sin_port = htons(MY_PORT_NUM);

ret = bind( listenSock, (struct sockaddr *)&servaddr, sizeof(servaddr) );

if (ret == -1) {
perror("bind");
exit(1);
}

/* Specify that a maximum of 5 streams will be available per socket */
memset( &initmsg, 0, sizeof(initmsg) );
initmsg.sinit_num_ostreams = 5;
initmsg.sinit_max_instreams = 5;
initmsg.sinit_max_attempts = 4;
ret = setsockopt( listenSock, IPPROTO_SCTP, SCTP_INITMSG,
&initmsg, sizeof(initmsg) );

/* Place the server socket into the listening state */
listen( listenSock, 5 );

/* Server loop... */
while( 1 ) {

/* Await a new client connection */
printf("Awaiting a new connection\n");
connSock = accept( listenSock, (struct sockaddr *)NULL, (int *)NULL );

/* New client socket has connected */

/* Grab the current time */
currentTime = time(NULL);

/* Send local time on stream 0 (local time stream) */
snprintf( buffer, MAX_BUFFER, "%s\n", ctime(&currentTime) );
ret = sctp_sendmsg( connSock, (void *)buffer, (size_t)strlen(buffer),
NULL, 0, 0, 0, LOCALTIME_STREAM, 0, 0 );

/* Send GMT on stream 1 (GMT stream) */
snprintf( buffer, MAX_BUFFER, "%s\n", asctime( gmtime( &currentTime ) ) );
ret = sctp_sendmsg( connSock, (void *)buffer, (size_t)strlen(buffer),
NULL, 0, 0, 0, GMT_STREAM, 0, 0 );

/* Close the client connection */
close( connSock );

}

return 0;
}



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





Archive powered by MHonArc 2.6.19+.

Top of page