<commit_before>#pragma once

#include <fcntl.h>
#include <netinet/tcp.h>
#include <sys/socket.h>

namespace happyntrain {

namespace network {

int setNonBlock(int fd, bool value = true) {
  int flags = fcntl(fd, F_GETFL, 0);
  if (flags < 0) {
    return errno;
  }
  flags = value ? flags | O_NONBLOCK : flags & ~O_NONBLOCK;
  return fcntl(fd, F_SETFL, flags);
}

// end network
}
// end happyntrain
}<commit_msg>Add socket func<commit_after>#pragma once

#include <fcntl.h>
#include <netinet/tcp.h>
#include <sys/socket.h>

#include <string>

namespace happyntrain {

namespace network {

inline int setNonBlock(int fd, bool value = true) {
  int flags = fcntl(fd, F_GETFL, 0);
  if (flags < 0) {
    return errno;
  }
  flags = value ? flags | O_NONBLOCK : flags & ~O_NONBLOCK;
  return fcntl(fd, F_SETFL, flags);
}

inline int new_tcp_socket() { return socket(AF_INET, SOCK_STREAM, 0); }

struct IP4Address {
  std::string host;
  short port;

  IP4Address(std::string host_, short port_) : host(host_), port(port_) {}
};

// end network
}
// end happyntrain
}
{'fraction_non_alphanumeric': 0.1352112676056338, 'fraction_numerical': 0.006572769953051643, 'mean_word_length': 3.958139534883721, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 10, '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': '5646675', 'n_tokens_mistral': 412, 'n_tokens_neox': 402, 'n_words': 108}