#include 
#include 
#include 
#include 
#include 

static int create_socket(const int attempt_number) {
    const int fd = socket(AF_INET6, SOCK_STREAM, 0);
    if (fd < 0) {
        fprintf(stderr, "socket creation failed on attempt %d,"
                " due to: %s\n", attempt_number, strerror(errno));
        return fd;
    }
    return fd;
}

int main() {
    const unsigned int num_times = 250000;
    for (unsigned int i = 1; i <= num_times; i++) {
        const int fd = create_socket(i);
        if (fd < 0) {
            return -1;
        }
        close(fd);
    }
    fprintf(stderr, "successfully created and closed %d sockets\n", num_times);
}
