sctp_bindx (Solaris sctp library) always return “Invalid argument”

纵饮孤独 提交于 2020-01-25 12:37:07

问题


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");
}  

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!


回答1:


You need to call bind first.

From the oracle docs on sctp_bindx

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/sctp-bindx-solaris-sctp-library-always-return-invalid-argument

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!