<commit_before>/* socket-client
 *
 * Simple socket client implementation
 * 2015 Yuzo(<NAME>)
 *
 * Client program arch:
 * 		Master thread: Recv message from server and print to cout. Block on recv().
 * 		Child thread: Read user input from cin and send to server. Block on getline().
 */

#include <iostream>
#include <thread>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <boost/format.hpp>

using namespace std;
using namespace boost;

const size_t BUFFER_SIZE = 1024;

void die(const char* message);
void show_usage();
void read_input(int client_fd);

int main(int argc, char* argv[]) {
	if (argc < 3) {
		cerr << "Error: hostname port required" << endl;
		cout << format("Usage: %1% <hostname> <port>") % argv[0] << endl;
		exit(EXIT_FAILURE);
	}

	int client_fd = socket(AF_INET, SOCK_STREAM, 0);
	if (client_fd < 0) {
		die("Error opening socket");
	}<commit_msg>port to windows<commit_after>/* socket-client
*
* Simple socket client implementation
* 2015 Yuzo(<NAME>)
*
* Client program arch:
* 		Master thread: Recv message from server and print to cout. Block on recv().
* 		Child thread: Read user input from cin and send to server. Block on getline().
*/

#include <iostream>
#include <thread>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <boost/format.hpp>

#ifdef _WIN32
	#define _WINSOCK_DEPRECATED_NO_WARNINGS
	#include <winsock2.h>
	#define close closesocket
	#pragma comment(lib, "ws2_32.lib")
#else
	#include <unistd.h>
	#include <sys/socket.h>
	#include <netinet/in.h>
	#include <netdb.h>
#endif

using namespace std;
using namespace boost;

const size_t BUFFER_SIZE = 1024;

void die(const char* message);
void show_usage();
void read_input(int client_fd);

int main(int argc, char* argv[]) {
	if (argc < 3) {
		cerr << "Error: hostname port required" << endl;
		cout << format("Usage: %1% <hostname> <port>") % argv[0] << endl;
		exit(EXIT_FAILURE);
	}

#ifdef _WIN32
	WSADATA wsa;
	if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0) {
		cerr << format("Error initializing winsock: %1%") % WSAGetLastError() << endl;
		exit(EXIT_FAILURE);
	}
#endif

	int client_fd = socket(AF_INET, SOCK_STREAM, 0);
	if (client_fd < 0) {
		die("Error opening socket");
	}
{'fraction_non_alphanumeric': 0.1436656508489334, 'fraction_numerical': 0.01654331737048324, 'mean_word_length': 4.6600985221674875, 'pattern_counts': {'":': 0, '<': 54, '<?xml version=': 0, '>': 30, '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': '887912', 'n_tokens_mistral': 876, 'n_tokens_neox': 835, 'n_words': 254}