<commit_before>//
//  Socket.swift
//  Socket
//
//  Created by <NAME> on 6/22/16.
//  Copyright © 2016-2017 <NAME>. All rights reserved.
//

import Foundation

public protocol TCPSocketDelegate: class {

	/// Called when a transport connects and is ready for reading and writing.
	func socketDidConnect(_ socket: TCPSocket)

	/// Called when a socket disconnects with or without error.
	///
	/// If you call the disconnect method, and the socket wasn't already disconnected,
	/// then an invocation of this delegate method will be enqueued on the delegateQueue
	/// before the disconnect method returns.
	func socket(_ socket: TCPSocket, didDisconnectWithError error: Error?)

	/// Called when a socket has read in data.
	func socket(_ socket: TCPSocket, didReceiveData data: Data)
	
	/// Called when an error occurs in socket.
	func socket(_ socket: TCPSocket, didFailWithError error: Error)

}

public class TCPSocket {
	
	public enum Status {
		case opening, opened, closed(Error?)
	}

	// MARK: -
	
	private static let workingThread = ThreadComponent.detachNew()
	
	private(set) public var unsafeDelegateQueue: DispatchQueue
	private(set) public var unsafeStatus: Status
	private(set) public var unsafeConfig: Config
	
	private(set) public weak var unsafeDelegate: TCPSocketDelegate?
	
	private var inputStreamDelegate: StreamDelegate?
	private var outputStreamDelegate: StreamDelegate?
	private var inputStream: InputStream?
	private var outputStream: OutputStream?
	
	// MARK: - 
	
	public var delegate: TCPSocketDelegate? {
		get {
			return synchronized(self) {
				return unsafeDelegate
			}
		}
		set {
			synchronized(self) {
				unsafeDelegate = newValue
			}
		}
	}<commit_msg>socket: fixed access modifiers for private properties<commit_after>//
//  Socket.swift
//  Socket
//
//  Created by <NAME> on 6/22/16.
//  Copyright © 2016-2017 <NAME>. All rights reserved.
//

import Foundation

public protocol TCPSocketDelegate: class {

	/// Called when a transport connects and is ready for reading and writing.
	func socketDidConnect(_ socket: TCPSocket)

	/// Called when a socket disconnects with or without error.
	///
	/// If you call the disconnect method, and the socket wasn't already disconnected,
	/// then an invocation of this delegate method will be enqueued on the delegateQueue
	/// before the disconnect method returns.
	func socket(_ socket: TCPSocket, didDisconnectWithError error: Error?)

	/// Called when a socket has read in data.
	func socket(_ socket: TCPSocket, didReceiveData data: Data)
	
	/// Called when an error occurs in socket.
	func socket(_ socket: TCPSocket, didFailWithError error: Error)

}

public class TCPSocket {
	
	public enum Status {
		case opening, opened, closed(Error?)
	}

	// MARK: -
	
	private static let workingThread = ThreadComponent.detachNew()

	private var unsafeDelegateQueue: DispatchQueue
	private var unsafeStatus: Status
	private var unsafeConfig: Config

	private weak var unsafeDelegate: TCPSocketDelegate?
	
	private var inputStreamDelegate: StreamDelegate?
	private var outputStreamDelegate: StreamDelegate?
	private var inputStream: InputStream?
	private var outputStream: OutputStream?
	
	// MARK: - 
	
	public var delegate: TCPSocketDelegate? {
		get {
			return synchronized(self) {
				return unsafeDelegate
			}
		}
		set {
			synchronized(self) {
				unsafeDelegate = newValue
			}
		}
	}
{'fraction_non_alphanumeric': 0.08155397390272835, 'fraction_numerical': 0.00771055753262159, 'mean_word_length': 3.7307152875175316, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3180976', 'n_tokens_mistral': 1031, 'n_tokens_neox': 913, 'n_words': 360}