我正在写一个SCTP测试程序在Solaris操作系统中,并使用Solaris原生SCTP堆栈。该程序如下所示:
if ((fd = socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP)) < 0) {
perror("socket");
}
addr.sin_family = AF_INET;
addr.sin_port = htons(9004);
addr.sin_addr.s_addr = inet_addr("192.168.23.117");
if (sctp_bindx(fd, (struct sockaddr*)&addr, sizeof(struct sockaddr_in), SCTP_BINDX_ADD_ADDR) < 0) {
perror("bind");
} 当运行程序时,它总是返回错误:“无效参数”。我已经使用gdb进行了检查,发现addr结构是正确的。
因为Solaris不是开源的,所以我只能使用gdb检查汇编代码,发现sctp_bindx调用setsockopt函数,并且setsockopt函数返回错误。调用setsockopt就像这样:
setsockopt(fd, SOL_SCTP, SCTP_ADD_ADDR, addrs, addrs_size); 我检查了所有的参数,发现它们是正确的。所以我找不出这个问题的原因。有人能帮帮我吗?提前感谢!
发布于 2013-05-23 03:05:33
您需要先调用bind。
来自sctp_bindx上的oracle文档
An application can use sctp_bindx(SCTP_BINDX_ADD_ADDR) to associate
additional addresses with an endpoint **after calling the bind() function**.https://stackoverflow.com/questions/16476770
复制相似问题