the return value of sctp_connectx do not match any error

Michael Tüxen Michael.Tuexen at lurchi.franken.de
Sun Dec 4 16:15:14 UTC 2011


On Dec 4, 2011, at 2:14 PM, jyl_2006 wrote:

> Yes, besides "127.0.0.1" , I also test between two computer, each one have ip
> address of wlan.The question still remains.
OK, I have tested RC2 i386 and it works. I don't have a Beta 2 system...
I have no idea what the problem might be... What does the following program
report?

Best regards
Michael

#include <sys/errno.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.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, ret;
	sctp_assoc_t _sctp_associd;
	struct sockaddr *show_ip_address = NULL;
	int size_of_addresses;
	socklen_t siz;
	struct sctp_getaddresses *addrs;

	_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_len = sizeof(struct sockaddr_in);
	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");
	}
	size_of_addresses = 0;
	siz = sizeof(int);
	if (getsockopt(_sctp_socket, IPPROTO_SCTP, SCTP_GET_LOCAL_ADDR_SIZE, &size_of_addresses, &siz) != 0) {
		perror("SCTP_GET_LOCAL_ADDR_SIZE");	
		return (-1);
	}
	printf("size_of_addresses = %d.\n", size_of_addresses);
	siz = size_of_addresses + sizeof(struct sockaddr_storage);
	siz += sizeof(struct sctp_getaddresses);
	addrs = calloc(1, siz);
	addrs->sget_assoc_id = _sctp_associd;
	if (getsockopt(_sctp_socket, IPPROTO_SCTP, SCTP_GET_LOCAL_ADDRESSES, addrs, &siz) != 0) {
		perror("SCTP_GET_LOCAL_ADDRESSES");
		return (-1);
	}
	printf("siz = %u.\n", siz);
	free(addrs);
	return (0);
}


> 
> --
> View this message in context: http://freebsd.1045724.n5.nabble.com/the-return-value-of-sctp-connectx-do-not-match-any-error-tp5041952p5046216.html
> Sent from the freebsd-net mailing list archive at Nabble.com.
> _______________________________________________
> freebsd-net at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-net
> To unsubscribe, send any mail to "freebsd-net-unsubscribe at freebsd.org"
> 



More information about the freebsd-net mailing list