<commit_before>//
//  AFConnectionServer.h
//  Amber
//
//  Created by <NAME> on 25/12/2008.
//  Copyright 2008 thirty-three software. All rights reserved.
//

#import "CoreNetworking/AFNetworkLayer.h"

#import "CoreNetworking/AFNetworkTypes.h"
#import "CoreNetworking/AFConnectionLayer.h"

@class AFNetworkSocket;
@class AFNetworkPool;
@class AFNetworkServer;

/*!
	@brief
	The server should consult the delegate for conditional operations. If your subclass provides a delegate protocol, it should conform to this one too.
 */
@protocol AFNetworkServerDelegate <AFConnectionLayerHostDelegate>

 @optional

/*
	@brief
	You can return FALSE to deny a client connectivity.
 
	@detail
	This is sent before each layer is opened, allowing you to make a progressive decision.
 */
- (BOOL)server:(AFNetworkServer *)server shouldAcceptConnection:(id <AFConnectionLayer>)connection;

@end

/*!
	@brief
	This is a generic construct for spawning new client layers.
	
	@detail
	After instantiating the server you can use one of the convenience methods to open socket(s)
 */
@interface AFNetworkServer : NSObject <AFNetworkServerDelegate, AFConnectionLayerHostDelegate> {
	id <AFNetworkServerDelegate> _delegate;
	
	NSArray *_encapsulationClasses;
	NSArray *_clientPools;
}

/*
	Host Addresses
 */

/*!
	@detail
	A collection of NSData objects containing either (struct sockaddr_in) or (struct sockaddr_in6).
	
	@result
	All the network socket addresses, these may be accessable from other network clients (ignoring firewall restrictions).
 */
+ (NSSet *)allInternetSocketAddresses;

/*!
	@detail
	A collection of NSData objects containing either (struct sockaddr_in) or (struct sockaddr_in6), however you shouldn't <em>need</em> to know this.
	This is likely only to be useful for testing your server, since it won't be accessable from another computer.
	
	@result
	All the localhost socket addresses, these are only accessible from the local machine.
	This allows you to create a server with ports open on all IP addresses that @"localhost" resolves to (equivalent to 127.0.0.1 and ::1).
 */
+ (NSSet *)localhostInternetSocketAddresses;

/*
	Initialization
 */

/*!
	@brief
	Override Constructor
 
	@detail
	This should call the designated initialiser with an appropriate |lowerLayer| and encapsulation class.
	By default this creates a server with no |lowerLayer| and <tt>AFNetworkTransport</tt> as the encapsulation class.
 */
+ (id)server;

/*!
	@brief
	Designated Initialiser.
 */
- (id)initWithEncapsulationClass:(Class)clientClass;
<commit_msg>Core Networking:<commit_after>//
//  AFConnectionServer.h
//  Amber
//
//  Created by <NAME> on 25/12/2008.
//  Copyright 2008 thirty-three software. All rights reserved.
//

#import "CoreNetworking/AFNetworkLayer.h"

#import "CoreNetworking/AFNetworkTypes.h"
#import "CoreNetworking/AFConnectionLayer.h"

@class AFNetworkSocket;
@class AFNetworkPool;
@class AFNetworkServer;

/*!
	@brief
	The server should consult the delegate for conditional operations. If your subclass provides a delegate protocol, it should conform to this one too.
 */
@protocol AFNetworkServerDelegate <AFConnectionLayerHostDelegate>

 @optional

/*
	@brief
	You can return FALSE to deny a client connectivity.
 
	@detail
	This is sent before each layer is opened, allowing you to make a progressive decision.
 */
- (BOOL)server:(AFNetworkServer *)server shouldAcceptConnection:(id <AFConnectionLayer>)connection;

@end

/*!
	@brief
	This is a generic construct for spawning new client layers.
	
	@detail
	After instantiating the server you can use one of the convenience methods to open socket(s)
 */
@interface AFNetworkServer : NSObject <AFNetworkServerDelegate, AFConnectionLayerHostDelegate> {
	id <AFNetworkServerDelegate> _delegate;
	
	NSArray *_encapsulationClasses;
	NSArray *_clientPools;
}

/*
	Host Addresses
 */

/*!
	@detail
	A collection of NSData objects containing either (struct sockaddr_in) or (struct sockaddr_in6).
	
	@result
	All the network socket addresses, these may be accessable from other network clients (ignoring firewall restrictions).
 */
+ (NSSet *)allInternetSocketAddresses;

/*!
	@detail
	A collection of NSData objects containing either (struct sockaddr_in) or (struct sockaddr_in6), however you shouldn't <em>need</em> to know this.
	This is likely only to be useful for testing your server, since it won't be accessable from another computer.
	
	@result
	All the localhost socket addresses, these are only accessible from the local machine.
	This allows you to create a server with ports open on all IP addresses that @"localhost" resolves to (equivalent to 127.0.0.1 and ::1).
 */
+ (NSSet *)localhostInternetSocketAddresses;

/*
	Initialization
 */

/*!
	@brief
	Designated Constructor.
	
	@detail
	This should call the designated initialiser with an appropriate encapsulation class. By default this creates a server with <tt>AFNetworkTransport</tt> as the encapsulation class.
 */
+ (id)server;

/*!
	@brief
	Designated Initialiser.
 */
- (id)initWithEncapsulationClass:(Class)clientClass;

{'fraction_non_alphanumeric': 0.08363059849385653, 'fraction_numerical': 0.008323424494649227, 'mean_word_length': 4.689966178128523, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2624375', 'n_tokens_mistral': 1483, 'n_tokens_neox': 1392, 'n_words': 546}