<commit_before>#include <stdio.h>
#include <sys/epoll.h>
#include <stdlib.h>
#include <fcntl.h>
#include <event.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <string.h>

#include "pink_socket.h"
#include "pink_util.h"

namespace pink {

ServerSocket::ServerSocket(int port, bool is_block) :
  port_(port),
  send_timeout_(0),
  recv_timeout_(0),
  accept_timeout_(0),
  accept_backlog_(1024),
  tcp_send_buffer_(0),
  tcp_recv_buffer_(0),
  keep_alive_(false),
  listening_(false),
  is_block_(is_block) {
  }

ServerSocket::~ServerSocket()
{
  Close();
}

void ServerSocket::Listen()
{
  sockfd_ = socket(AF_INET, SOCK_STREAM, 0);
  memset(&servaddr_, 0, sizeof(servaddr_));

  int yes = 1;
  if (setsockopt(sockfd_, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) == -1) {
  }

  servaddr_.sin_family = AF_INET;
  servaddr_.sin_addr.s_addr = htonl(INADDR_ANY);
  servaddr_.sin_port = htons(port_);

  int ret = bind(sockfd_, (struct sockaddr *) &servaddr_, sizeof(servaddr_));
  if (ret < 0) {
    fprintf(stderr, "bind port error");
    exit(-1);
  }
  listen(sockfd_, accept_backlog_);
  listening_ = true;

  if (is_block_ == false) {
    SetNonBlock();
  }

}

int ServerSocket::SetNonBlock()
{
  flags_ = Setnonblocking(sockfd());
  if (flags_ == -1) {
    return -1;
  }
  return 0;
}

void ServerSocket::Close()
{<commit_msg>add newline to bind error output<commit_after>#include <stdio.h>
#include <sys/epoll.h>
#include <stdlib.h>
#include <fcntl.h>
#include <event.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <string.h>

#include "pink_socket.h"
#include "pink_util.h"

namespace pink {

ServerSocket::ServerSocket(int port, bool is_block) :
  port_(port),
  send_timeout_(0),
  recv_timeout_(0),
  accept_timeout_(0),
  accept_backlog_(1024),
  tcp_send_buffer_(0),
  tcp_recv_buffer_(0),
  keep_alive_(false),
  listening_(false),
  is_block_(is_block) {
  }

ServerSocket::~ServerSocket()
{
  Close();
}

void ServerSocket::Listen()
{
  sockfd_ = socket(AF_INET, SOCK_STREAM, 0);
  memset(&servaddr_, 0, sizeof(servaddr_));

  int yes = 1;
  if (setsockopt(sockfd_, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) == -1) {
  }

  servaddr_.sin_family = AF_INET;
  servaddr_.sin_addr.s_addr = htonl(INADDR_ANY);
  servaddr_.sin_port = htons(port_);

  int ret = bind(sockfd_, (struct sockaddr *) &servaddr_, sizeof(servaddr_));
  if (ret < 0) {
    fprintf(stderr, "\nbind port error!\n");
    exit(-1);
  }
  listen(sockfd_, accept_backlog_);
  listening_ = true;

  if (is_block_ == false) {
    SetNonBlock();
  }

}

int ServerSocket::SetNonBlock()
{
  flags_ = Setnonblocking(sockfd());
  if (flags_ == -1) {
    return -1;
  }
  return 0;
}

void ServerSocket::Close()
{
{'fraction_non_alphanumeric': 0.1608166189111748, 'fraction_numerical': 0.012893982808022923, 'mean_word_length': 4.563745019920319, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 23, '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': '5173041', 'n_tokens_mistral': 1140, 'n_tokens_neox': 1109, 'n_words': 211}