2013-05-10 13 views
0

我正在Solaris操作系統中編寫SCTP測試程序,並使用Solaris本機SCTP堆棧。程序喜歡這個:sctp_bindx(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); 

我已經檢查的所有參數,並發現他們是正確的。所以我無法弄清楚這個問題的原因。任何人都可以幫我嗎?提前致謝!

+0

此問題已得到修復:在Solaris操作系統,調用則sctp_bindx之前,端點必須使用綁定的約束。這可以由人來改變。 – 2013-05-12 03:23:50

回答

0

您需要先調用綁定。

從Oracle文檔上sctp_bindx

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

我找到了原因,但也非常感謝你! – 2013-05-23 01:03:58