the return value of sctp_connectx do not match any error
jyl_2006
yilinjing2006 at gmail.com
Sat Dec 3 04:54:47 UTC 2011
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.
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.
One more thing, I also test these programs in other platform, the result is
OK, but under FreeBSD, it does not work.
/*Here are programs.*/
#include <sys/errno.h>
#include <stdio.h>
#include <string.h>
#include <netinet/in.h>
#include <netinet/sctp.h>
#include <sys/types.h>
#include <sys/socket.h>
#define PORT 63000
#define MTU 1500
int main()
{
int _listenfd, _sctp_socket, _connfd;
struct sockaddr_in servaddr;
int ret, msg_flag;
char message[MTU];
struct sctp_sndrcvinfo sndrcvinfo;
_sctp_socket = socket( AF_INET , SOCK_SEQPACKET , IPPROTO_SCTP );
bzero( (void *)&servaddr, sizeof(servaddr) );
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl( INADDR_ANY );
servaddr.sin_port = htons(PORT);
ret = bind(_sctp_socket, (struct sockaddr *)&servaddr, sizeof(servaddr));
if( ret )
{
printf("Server bind error" );
}
_listenfd= listen(_sctp_socket, 10);
if(0 != _listenfd)
{
printf("Server listen error" );
}
ret = sctp_recvmsg(_sctp_socket, (void *)message , MTU, NULL, 0 ,
&sndrcvinfo , &msg_flag);
if(ret >= 0)
{
printf("Receive message:%s", message);
}
}
#include <sys/errno.h>
#include <stdio.h>
#include <string.h>
#include <netinet/in.h>
#include <netinet/sctp.h>
#include <sys/types.h>
#include <sys/socket.h>
#define PORT 63000
int main()
{
int _sctp_socket, _sctp_associd, ret;
_sctp_socket = socket( AF_INET , SOCK_SEQPACKET , IPPROTO_SCTP );
struct sockaddr_in server_ipaddress;
server_ipaddress . sin_family = AF_INET;
server_ipaddress . sin_port = htons(PORT);
server_ipaddress . sin_addr.s_addr = inet_addr("127.0.0.1");
ret = sctp_connectx(_sctp_socket , (struct sockaddr*) &server_ipaddress ,
1, &_sctp_associd);
if( ret < 0)
{
printf("sctp_connectx error");
}
}
--
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.
More information about the freebsd-net
mailing list