From owner-freebsd-net@FreeBSD.ORG Sat Dec 3 07:29:41 2011 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6E6CC106566C for ; Sat, 3 Dec 2011 07:29:41 +0000 (UTC) (envelope-from Michael.Tuexen@lurchi.franken.de) Received: from mail-n.franken.de (drew.ipv6.franken.de [IPv6:2001:638:a02:a001:20e:cff:fe4a:feaa]) by mx1.freebsd.org (Postfix) with ESMTP id 4C12F8FC0C for ; Sat, 3 Dec 2011 07:29:40 +0000 (UTC) Received: from [192.168.1.200] (p508F9B37.dip.t-dialin.net [80.143.155.55]) (Authenticated sender: macmic) by mail-n.franken.de (Postfix) with ESMTP id 77FEA1C0C0BCE; Sat, 3 Dec 2011 08:29:38 +0100 (CET) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=us-ascii From: =?iso-8859-1?Q?Michael_T=FCxen?= In-Reply-To: <1322888085250-5043901.post@n5.nabble.com> Date: Sat, 3 Dec 2011 08:29:37 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <1322834879026-5041952.post@n5.nabble.com> <0D6FA7F2-1462-44EF-98F4-3B6AFC856757@lurchi.franken.de> <1322888085250-5043901.post@n5.nabble.com> To: jyl_2006 X-Mailer: Apple Mail (2.1251.1) Cc: freebsd-net@freebsd.org Subject: Re: the return value of sctp_connectx do not match any error X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Dec 2011 07:29:41 -0000 On Dec 3, 2011, at 5:54 AM, jyl_2006 wrote: > First, I use the return value of sctp_connectx, and I do not use = errno, so > the return value does not match the errors gived in manual. Now,I know = it is > my mistake. >=20 > However, I write a simple program to test sctp_connectx, it still show > error.The errno is "EINVAL", I am sure that the paraments are set = properly. >=20 > One more thing, I also test these programs in other platform, the = result is > OK, but under FreeBSD, it does not work. In BSD you need to set the sin_len field of the sockaddr_in structure. So if you add server_ipaddress . sin_len =3D sizeof(struct sockaddr_in); the client works (at least it does for me). You should do the same for the server... Please let me know if your problem persists. Best regards Michael >=20 > /*Here are programs.*/ >=20 > #include > #include > #include >=20 > #include > #include > #include > #include > #define PORT 63000 > #define MTU 1500 >=20 > int main() > { > int _listenfd, _sctp_socket, _connfd; > struct sockaddr_in servaddr; > int ret, msg_flag; > char message[MTU]; > struct sctp_sndrcvinfo sndrcvinfo; > =09 > _sctp_socket =3D socket( AF_INET , SOCK_SEQPACKET , IPPROTO_SCTP = ); >=20 > bzero( (void *)&servaddr, sizeof(servaddr) ); > servaddr.sin_family =3D AF_INET; > servaddr.sin_addr.s_addr =3D htonl( INADDR_ANY ); > servaddr.sin_port =3D htons(PORT); >=20 > ret =3D bind(_sctp_socket, (struct sockaddr *)&servaddr, = sizeof(servaddr)); > if( ret ) > { > printf("Server bind error" ); > } >=20 > _listenfd=3D listen(_sctp_socket, 10); > if(0 !=3D _listenfd) > { > printf("Server listen error" ); > } >=20 > ret =3D sctp_recvmsg(_sctp_socket, (void *)message , MTU, NULL, = 0 , > &sndrcvinfo , &msg_flag); > if(ret >=3D 0) > { > printf("Receive message:%s", message); > } > } > =09 >=20 > #include > #include > #include >=20 > #include > #include > #include > #include > #define PORT 63000 >=20 > int main() > { > int _sctp_socket, _sctp_associd, ret; > _sctp_socket =3D socket( AF_INET , SOCK_SEQPACKET , IPPROTO_SCTP = ); >=20 > struct sockaddr_in server_ipaddress; > server_ipaddress . sin_family =3D AF_INET; > server_ipaddress . sin_port =3D htons(PORT); > server_ipaddress . sin_addr.s_addr =3D inet_addr("127.0.0.1"); >=20 > ret =3D sctp_connectx(_sctp_socket , (struct sockaddr*) = &server_ipaddress , > 1, &_sctp_associd); > if( ret < 0) > { > printf("sctp_connectx error"); > } > } > =09 > =09 >=20 > =09 >=20 >=20 > -- > View this message in context: = http://freebsd.1045724.n5.nabble.com/the-return-value-of-sctp-connectx-do-= not-match-any-error-tp5041952p5043901.html > Sent from the freebsd-net mailing list archive at Nabble.com. > _______________________________________________ > freebsd-net@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-net > To unsubscribe, send any mail to "freebsd-net-unsubscribe@freebsd.org" >=20