static int socket_open_listen(struct sockaddr_in *my_addr)

{

    int server_fd, tmp;



    server_fd = socket(AF_INET,SOCK_STREAM,0);

    if (server_fd < 0) {

        perror ("socket");

        return -1;

    }



    tmp = 1;

    setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp));




    if (bind (server_fd, (struct sockaddr *) my_addr, sizeof (*my_addr)) < 0) {

        char bindmsg[32];

        snprintf(bindmsg, sizeof(bindmsg), "bind(port %d)", ntohs(my_addr->sin_port));

        perror (bindmsg);

        closesocket(server_fd);

        return -1;

    }



    if (listen (server_fd, 5) < 0) {

        perror ("listen");

        closesocket(server_fd);

        return -1;

    }

    ff_socket_nonblock(server_fd, 1);



    return server_fd;

}
static int socket_open_listen(struct sockaddr_in *my_addr)

{

    int server_fd, tmp;



    server_fd = socket(AF_INET,SOCK_STREAM,0);

    if (server_fd < 0) {

        perror ("socket");

        return -1;

    }



    tmp = 1;

    setsockopt(server_fd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof(tmp));




    if (bind (server_fd, (struct sockaddr *) my_addr, sizeof (*my_addr)) < 0) {

        char bindmsg[32];

        snprintf(bindmsg, sizeof(bindmsg), "bind(port %d)", ntohs(my_addr->sin_port));

        perror (bindmsg);

        closesocket(server_fd);

        return -1;

    }



    if (listen (server_fd, 5) < 0) {

        perror ("listen");

        closesocket(server_fd);

        return -1;

    }

    ff_socket_nonblock(server_fd, 1);



    return server_fd;

}
static int FUNC_0(struct sockaddr_in *VAR_0)

{

    int VAR_1, VAR_2;



    VAR_1 = socket(AF_INET,SOCK_STREAM,0);

    if (VAR_1 < 0) {

        perror ("socket");

        return -1;

    }



    VAR_2 = 1;

    setsockopt(VAR_1, SOL_SOCKET, SO_REUSEADDR, &VAR_2, sizeof(VAR_2));




    if (bind (VAR_1, (struct sockaddr *) VAR_0, sizeof (*VAR_0)) < 0) {

        char VAR_3[32];

        snprintf(VAR_3, sizeof(VAR_3), "bind(port %d)", ntohs(VAR_0->sin_port));

        perror (VAR_3);

        closesocket(VAR_1);

        return -1;

    }



    if (listen (VAR_1, 5) < 0) {

        perror ("listen");

        closesocket(VAR_1);

        return -1;

    }

    ff_socket_nonblock(VAR_1, 1);



    return VAR_1;

}
static int FUNC_0(struct sockaddr_in *VAR_0)
{ int VAR_1, VAR_2; VAR_1 = socket(AF_INET,SOCK_STREAM,0); if (VAR_1 < 0) { perror ("socket"); return -1; } VAR_2 = 1; setsockopt(VAR_1, SOL_SOCKET, SO_REUSEADDR, &VAR_2, sizeof(VAR_2)); if (bind (VAR_1, (struct sockaddr *) VAR_0, sizeof (*VAR_0)) < 0) { char VAR_3[32]; snprintf(VAR_3, sizeof(VAR_3), "bind(port %d)", ntohs(VAR_0->sin_port)); perror (VAR_3); closesocket(VAR_1); return -1; } if (listen (VAR_1, 5) < 0) { perror ("listen"); closesocket(VAR_1); return -1; } ff_socket_nonblock(VAR_1, 1); return VAR_1; }