RE: lksctp bind problem(address in use)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello.


> What are you using to bind the port, sctp_bindx() ?

I don't use sctp bindx(). 
I use bind().
After I received the e-mail, I tried to use sctp_bindx(). But I have the same error.

> And is it the bind or the connect that complains about address in use?
> Asking because I couldn't spot any relevant change on sctp_bindx() between those releases while for sctp_connectx() there are quite some.

I have a problem with bind() before connect().

I attach the sample code that I use for test.

Best, Regard.

int main(int argc, char *argv[])
{
    struct sockaddr_in  addr_in;
    unsigned short      usPort = atoi(argv[2]);
    char                strIp[32];
    int                 fd1, fd2, nRet;


    strcpy(strIp, argv[1]);


    memset(&addr_in, 0x00, sizeof(struct sockaddr_in));
    addr_in.sin_family = AF_INET;
    addr_in.sin_port = htons(usPort);
    nRet = inet_pton(AF_INET, strIp, &addr_in.sin_addr.s_addr);
    if (nRet <= 0)
    {
        printf("inet_pton fail(%d) addr(%s:%d)\n", errno, strIp, usPort);
        return -1;
    }


    /* listen socket */
    fd1 = socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP);
    if (fd1 < 0)
    {
        printf("socket fail(%d) addr(%s:%d)\n", errno, strIp, usPort);
        return -1;
    }

    nRet = 1;
    setsockopt(fd1, SOL_SOCKET, SO_REUSEADDR, (const void *) &nRet, sizeof(nRet));

    if(bind(fd1, (struct sockaddr *) &addr_in, sizeof(struct sockaddr_in)) < 0)
    {
        printf("bind fail(%d) addr(%s:%d)\n", errno, strIp, usPort);
        close(fd1);
        return -1;
    }

    if(listen(fd1, SOMAXCONN) < 0)
    {
        printf("listen fail(%d) addr(%s:%d)\n", errno, strIp, usPort);
        close(fd1);
        return -1;
    }


    /* bind socket */
    fd2 = socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP);
    if (fd2 < 0)
    {
        printf("2: socket fail(%d) addr(%s:%d)\n", errno, strIp, usPort);
        return -1;
    }

    nRet = 1;
    setsockopt(fd2, SOL_SOCKET, SO_REUSEADDR, (const void *) &nRet, sizeof(nRet));

    if(bind(fd2, (struct sockaddr *) &addr_in, sizeof(struct sockaddr_in)) < 0)
    {
        printf("2: bind fail(%d) addr(%s:%d)\n", errno, strIp, usPort);
        close(fd1);
        return -1;
    }

    return 0;
}

-----Original Message-----
From: Marcelo Ricardo Leitner [mailto:marcelo.leitner@xxxxxxxxx] 
Sent: Friday, March 11, 2016 10:50 PM
To: �迵��
Cc: linux-sctp@xxxxxxxxxxxxxxx; ���뿬 ����
Subject: Re: lksctp bind problem(address in use)

Hi,

On Fri, Mar 11, 2016 at 09:56:01AM +0900,  迵   wrote:
> 
> Hello
> 
> I have a problem.
> 
> Until lksctp 1.0.6, I can use the following case
> 
> - one "server" socket, bind to the port 36412, listening for incoming 
> connection
> - one or more "client" sockets, bind to the same port (36412) for 
> outgoing connection.
> 
> But In lksctp 1.0.13, we have a problem.
> 
> I need this for Association Restart Service.
> I have 2 Sctp Server.
> They work by Active - standby.
> If the active server is down, the other server will bind and listen 
> the port 36412 for active action.
> Then, the other server will bind the port for Restart Service, too.
> But. Now we have error( address in use).
> 
> How can I solve the problem.

What are you using to bind the port, sctp_bindx() ?
And is it the bind or the connect that complains about address in use?
Asking because I couldn't spot any relevant change on sctp_bindx() between those releases while for sctp_connectx() there are quite some.

  Marcelo




--
To unsubscribe from this list: send the line "unsubscribe linux-sctp" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Networking Development]     [Linux OMAP]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux