简体   繁体   English

协议特定的套接字创建和套接字选项信息

[英]Protocol specific Socket creation and socket option information

I am trying to create a socket of sctp and then retrieve the socket options information, using sctp_opt_info(). 我正在尝试创建一个sctp套接字,然后使用sctp_opt_info()检索套接字选项信息。

I am successfully able to create the specific socket however on socket option retrieval I am getting the value as -1 indication some error. 我能够成功创建特定的套接字,但是在套接字选项检索中,我得到的值是-1,指示某些错误。 The error is because of invalid arguments of sctp_opt_info(). 该错误是由于sctp_opt_info()的参数无效。

Can some one please guide me what is wrong. 可以请一个人指导我怎么了。 Why am I getting -1 for this call and not 0(success indicator) 为什么我为此呼叫得到-1而不是0(成功指示符)

int socket_desc;
struct sockaddr_in  sin[1]; 
unsigned int len;
int val1,val2; 
char s[100]; 

struct sctp_rtoinfo {
    sctp_assoc_t    srto_assoc_id;
    uint32_t        srto_initial;
    uint32_t        srto_max; 
    uint32_t        srto_min;
}rto;


socket_desc=socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP);
if (socket_desc==-1)
  printf("Socket Fail");

val1 = sctp_opt_info(socket_desc,IPPROTO_SCTP,SCTP_RTOINFO,&rto,&len);

printf("Erro : %d, \n", errno );
perror(s);
printf("Status opt info: %d\n",val1);

I am getting the val1 value as -1 indicating some problem. 我将val1值设为-1表示存在问题。 The perror says invalid argument for sctp_opt_info(). 错误表明sctp_opt_info()的参数无效。 My guess is argument two of this function , not sure though. 我的猜测是此函数的参数二,虽然不确定。

Any help will be appreciated. 任何帮助将不胜感激。

Thanks 谢谢

len , the last parameter to sctp_opt_info() is a value-result parameter. lensctp_opt_info()的最后一个参数是一个值结果参数。 You have to atleast initialize it to the length of the parameter you pass in, 您必须至少将其初始化为您传入的参数的长度,

len = sizeof rto;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM