Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Dec 2011 20:54:45 -0800 (PST)
From:      jyl_2006 <yilinjing2006@gmail.com>
To:        freebsd-net@freebsd.org
Subject:   Re: the return value of sctp_connectx do not match any error
Message-ID:  <1322888085250-5043901.post@n5.nabble.com>
In-Reply-To: <0D6FA7F2-1462-44EF-98F4-3B6AFC856757@lurchi.franken.de>
References:  <1322834879026-5041952.post@n5.nabble.com> <0D6FA7F2-1462-44EF-98F4-3B6AFC856757@lurchi.franken.de>

next in thread | previous in thread | raw e-mail | index | archive | help
First, I use the return value of sctp_connectx, and I do not use errno, so
the return value does not match the errors gived in manual. Now,I know it is
my mistake.

However, I write a simple program to test sctp_connectx, it still show
error.The errno is "EINVAL", I am sure that the paraments are set properly.

One more thing, I also test these programs in other platform, the result is
OK, but under FreeBSD, it does not work.

/*Here are programs.*/

#include <sys/errno.h>
#include <stdio.h>
#include <string.h>

#include <netinet/in.h>
#include <netinet/sctp.h>
#include <sys/types.h>
#include <sys/socket.h>
#define PORT 63000
#define MTU  1500

int main()
{
	int _listenfd, _sctp_socket, _connfd;
	struct sockaddr_in servaddr;
	int ret, msg_flag;
	char message[MTU];
	struct sctp_sndrcvinfo sndrcvinfo;
	
	_sctp_socket = socket( AF_INET , SOCK_SEQPACKET , IPPROTO_SCTP );

	bzero( (void *)&servaddr, sizeof(servaddr) );
	servaddr.sin_family = AF_INET;
	servaddr.sin_addr.s_addr = htonl( INADDR_ANY );
	servaddr.sin_port = htons(PORT);

	ret = bind(_sctp_socket, (struct sockaddr *)&servaddr, sizeof(servaddr));
	if( ret )
	{
		printf("Server bind error" );
	}

	_listenfd= listen(_sctp_socket, 10);
	if(0 != _listenfd)
	{
		printf("Server listen error" );
	}

	ret = sctp_recvmsg(_sctp_socket, (void *)message , MTU, NULL, 0 ,
&sndrcvinfo , &msg_flag);
	if(ret >= 0)
	{
		printf("Receive message:%s", message);
	}
}
	

#include <sys/errno.h>
#include <stdio.h>
#include <string.h>

#include <netinet/in.h>
#include <netinet/sctp.h>
#include <sys/types.h>
#include <sys/socket.h>
#define PORT 63000

int main()
{
	int _sctp_socket, _sctp_associd, ret;
	_sctp_socket = socket( AF_INET , SOCK_SEQPACKET , IPPROTO_SCTP );

	struct sockaddr_in server_ipaddress;
	server_ipaddress . sin_family = AF_INET;
	server_ipaddress . sin_port = htons(PORT);
	server_ipaddress . sin_addr.s_addr = inet_addr("127.0.0.1");

	ret = sctp_connectx(_sctp_socket , (struct sockaddr*) &server_ipaddress ,
1, &_sctp_associd);
        if( ret < 0)
        {
		printf("sctp_connectx error");
        }
}
	
	

	


--
View this message in context: http://freebsd.1045724.n5.nabble.com/the-return-value-of-sctp-connectx-do-not-match-any-error-tp5041952p5043901.html
Sent from the freebsd-net mailing list archive at Nabble.com.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1322888085250-5043901.post>