<commit_before>/*
 *	socket.h
 *	Nashoba Robotics
 *
 *	Copyright 2010 <NAME>
 *	All Rights Reserved
 */

#include <typeinfo>
#include <string>

#include <netinet/in.h>

namespace nr
{
	namespace net
	{
		class socket_exception : public std::exception
		{
		public:
			socket_exception( const char *desc ) throw ();
			virtual ~socket_exception() throw () {}

			const char* what() const throw ();

		private:
			std::string description;
		};

		class socket
		{
		public:
			socket( bool server = false ) throw ( socket_exception );
			virtual ~socket() throw ();

			// Server socket
			socket& bind( int port ) throw ( socket_exception );
			socket& listen( int max_connections = 10 ) throw ( socket_exception );
			socket accept() const throw ( socket_exception );
			socket* accept_ref() const throw ( socket_exception );

			// Client sockets
			bool connect( const std::string& host, int port ) throw ( socket_exception );

			// Data Transmission
			bool write( const std::string& ) const throw ( socket_exception );
			size_t read( std::string& ) const throw ( socket_exception );

			const socket& operator<<( const std::string& ) const throw ( socket_exception );
			const socket& operator>>( std::string& ) const throw ( socket_exception );

			void close() throw ( socket_exception );

			// Validity
			bool valid() const throw ();

			// Options
			void set_nonblocking( bool nonblocking ) throw ();

			bool explicit_close;

			static const size_t kMaxReceiveLength = 4096;

		private:
			int fd;
			struct ::sockaddr_in address_info;
		};
	}
}
<commit_msg>Added a #pragma once at the top of net/socket.h<commit_after>/*
 *	socket.h
 *	Nashoba Robotics
 *
 *	Copyright 2010 <NAME>
 *	All Rights Reserved
 */

#pragma once

#include <typeinfo>
#include <string>

#include <netinet/in.h>

namespace nr
{
	namespace net
	{
		class socket_exception : public std::exception
		{
		public:
			socket_exception( const char *desc ) throw ();
			virtual ~socket_exception() throw () {}

			const char* what() const throw ();

		private:
			std::string description;
		};

		class socket
		{
		public:
			socket( bool server = false ) throw ( socket_exception );
			virtual ~socket() throw ();

			// Server socket
			socket& bind( int port ) throw ( socket_exception );
			socket& listen( int max_connections = 10 ) throw ( socket_exception );
			socket accept() const throw ( socket_exception );
			socket* accept_ref() const throw ( socket_exception );

			// Client sockets
			bool connect( const std::string& host, int port ) throw ( socket_exception );

			// Data Transmission
			bool write( const std::string& ) const throw ( socket_exception );
			size_t read( std::string& ) const throw ( socket_exception );

			const socket& operator<<( const std::string& ) const throw ( socket_exception );
			const socket& operator>>( std::string& ) const throw ( socket_exception );

			void close() throw ( socket_exception );

			// Validity
			bool valid() const throw ();

			// Options
			void set_nonblocking( bool nonblocking ) throw ();

			bool explicit_close;

			static const size_t kMaxReceiveLength = 4096;

		private:
			int fd;
			struct ::sockaddr_in address_info;
		};
	}
}

{'fraction_non_alphanumeric': 0.11396368190356919, 'fraction_numerical': 0.006261740763932373, 'mean_word_length': 3.4747899159663866, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, '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': '6664475', 'n_tokens_mistral': 1103, 'n_tokens_neox': 916, 'n_words': 304}