bind to address localhost:0 error -98 (Address already in use)

General support questions
Post Reply
IgorMelen
Posts: 1
Joined: 2018/12/17 08:59:12

bind to address localhost:0 error -98 (Address already in use)

Post by IgorMelen » 2018/12/17 09:29:54

About once a day, a critical error occurs. Failure of some programs.

Code: Select all

bind to address localhost:0 - Address already in use
There are definitely free ports. Port 0 cannot be busy.
I ask you to tell what resources of system can not be enough for performance of bind (0).
What operating system parameters should be monitored?

Test:

Code: Select all

  memset(&addr, 0, sizeof(struct sockaddr_in));
    addr.sin_family = AF_INET;
    addr.sin_addr.s_addr = INADDR_ANY;
    addr.sin_port = htons(0);

    if(bind(sock, (struct sockaddr *) &addr, sizeof(struct sockaddr_in))<0)
    {

        perror("bind");
        exit(-1);
    }
(https://stackoverflow.com/questions/575 ... ng-0-0-0-0)

strace:

socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = 3
bind(3, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EADDRINUSE (Address already in use)

dunch
Posts: 66
Joined: 2018/11/07 13:48:53
Location: Yorkshire

Re: bind to address localhost:0 error -98 (Address already in use)

Post by dunch » 2018/12/19 10:04:26

Anything in audit.log?

Post Reply