<commit_before>//
// Created by WangHaohan on 2/19/16.
//

#include "SocketServer.h"

SocketServer::SocketServer(int protno) { this->portno = protno; }

int SocketServer::serve(int times) {
    pthread_t thread;
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (sockfd < 0)
        throw std::runtime_error("ERROR opening socket");
    bzero((char *) &serv_addr, sizeof(serv_addr));
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = INADDR_ANY;
    serv_addr.sin_port = htons(portno);
    if (bind(sockfd, (struct sockaddr *) &serv_addr,
             sizeof(serv_addr)) < 0) {
        throw std::runtime_error("ERROR on binding");
    }
    listen(sockfd, 5);
    clilen = sizeof(cli_addr);

    int i = 0;
    while (i < times) {
        /* accept incoming connections */
        newsockfd = accept(sockfd,
                           (struct sockaddr *) &cli_addr,<commit_msg>minor fix on socket, for differences between mac and linux<commit_after>//
// Created by WangHaohan on 2/19/16.
//

#include "SocketServer.h"

SocketServer::SocketServer(int protno) { this->portno = protno; }

int SocketServer::serve(int times) {
    pthread_t thread;
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (sockfd < 0)
        throw std::runtime_error("ERROR opening socket");
    bzero((char *) &serv_addr, sizeof(serv_addr));
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = INADDR_ANY;
    serv_addr.sin_port = htons(portno);
    if (::bind(sockfd, (struct sockaddr *) &serv_addr, // use ::bind for mac, use bind for linux
             sizeof(serv_addr)) < 0) {
        throw std::runtime_error("ERROR on binding");
    }
    listen(sockfd, 5);
    clilen = sizeof(cli_addr);

    int i = 0;
    while (i < times) {
        /* accept incoming connections */
        newsockfd = accept(sockfd,
                           (struct sockaddr *) &cli_addr,
{'fraction_non_alphanumeric': 0.1293057763645999, 'fraction_numerical': 0.010598834128245893, 'mean_word_length': 2.8609406952965237, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7630693', 'n_tokens_mistral': 648, 'n_tokens_neox': 628, 'n_words': 148}