Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bindx() returns EINVAL #53

Closed
rsecchi opened this issue Feb 15, 2016 · 1 comment
Closed

bindx() returns EINVAL #53

rsecchi opened this issue Feb 15, 2016 · 1 comment

Comments

@rsecchi
Copy link

rsecchi commented Feb 15, 2016

Hi,

I tried to use bindx() like the example below in Linux. While the individual bind() work (commented out), the bindx() doesn't. Is it the correct syntax?

Thanks in advance.

#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <usrsctp.h>
#include <stdarg.h>

#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>


static inline void CHECK(int val, char* str)
{
        if (val!=0) {
                perror(str);
                exit(1);
        }
}

int main(void) 
{
        struct socket* sk; 
        struct sockaddr_in addr[2];

        usrsctp_init(0, NULL, NULL);

        int rv; 

        /* create a socket 1-to-many */
        sk = usrsctp_socket(AF_INET, SOCK_SEQPACKET, IPPROTO_SCTP, 
                NULL, NULL, 0, NULL);   
        CHECK(sk==NULL, "usrsctp_socket");

        /* bind the socket to a local addr */ 
        addr[0].sin_family = AF_INET;
        addr[0].sin_port = htons(5000);
        addr[0].sin_addr.s_addr = inet_addr("127.0.0.1");

        addr[1].sin_family = AF_INET;
        addr[1].sin_port = htons(5000);
        addr[1].sin_addr.s_addr = inet_addr("127.0.0.2");

        rv = usrsctp_bindx(sk, (struct sockaddr *)addr, 2, SCTP_BINDX_ADD_ADDR);
        // rv = usrsctp_bind(sk, (struct sockaddr *)&addr[0], sizeof(struct sockaddr_in));
        // rv = usrsctp_bind(sk, (struct sockaddr *)&addr[1], sizeof(struct sockaddr_in));
        CHECK(rv<0, "usrsctp_bind"); 

        return 0;
}
tuexen added a commit that referenced this issue Feb 15, 2016
@tuexen
Copy link
Member

tuexen commented Feb 15, 2016

After small changes in your test program I could reproduce your problem. It is fixed in f499b4e.
Please test and close the issue if it is also fixed for you.
Thanks for reporting.

@rsecchi rsecchi closed this as completed Feb 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants