sctp_bindx(Solaris sctp库)始终返回“无效参数". [英] sctp_bindx (Solaris sctp library) always return "Invalid argument"

查看:416
本文介绍了sctp_bindx(Solaris sctp库)始终返回“无效参数".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Solaris OS中编写SCTP测试程序,并使用Solaris本机SCTP堆栈.该程序是这样的:

I am writing a SCTP test program in Solaris OS, and use Solaris native SCTP stack. The program likes this:

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就像这样:

When running the program, it always return error:"Invalid argument". I have used the gdb to check, and find addr structure is right.
Because Solaris isn't open source, I can only check the assembly code using gdb, and find sctp_bindx calls setsockopt function, and the setsockopt function return error. The calling setsockopt likes this:

setsockopt(fd, SOL_SCTP, SCTP_ADD_ADDR, addrs, addrs_size);  

我检查了所有参数,发现它们是正确的.因此,我无法找出造成此问题的原因.有人可以帮我吗?预先感谢!

I have checked all the parameters, and find they are right. So I can't figure out the cause of this issue. Could anyone help me? Thanks in advance!

推荐答案

您需要先调用绑定.

来自 sctp_bindx

An application can use sctp_bindx(SCTP_BINDX_ADD_ADDR) to associate 
additional addresses with an endpoint **after calling the bind() function**.

这篇关于sctp_bindx(Solaris sctp库)始终返回“无效参数".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆