- From: nitin rakh <nitinrakh AT gmail.com>
- To: sctp-discussion AT sctp.de
- Subject: [SCTP-Discussion] setsockopt() returning invalid argument
- Date: Mon, 9 Mar 2009 21:38:12 +0530
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=iy17Ch8yK9wE6LB1Eug1pa6XSZ5XWJuTuT+6OkQ0uWvTKDm8Yq1aHZFQnIClmVTsXy TJ2wLnI0opZps8wzC8IlhlkYDrfqaC6pnM5g6X0FP7eB1ZYwBx2UZec9BOtvfMKSYcWJ Fojhr6SUBgiiuna1zoIUtxqoUAB2wrEdonK7g=
- List-archive: <http://lists.franken.de/pipermail/sctp-discussion>
- List-id: SCTP Discussions <sctp-discussion.sctp.de>
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(¤tTime) );
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( ¤tTime ) ) );
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;
}
Archive powered by MHonArc 2.6.19+.