<commit_before>![Logo](Swocket.png)

[![CI Status](http://img.shields.io/travis/<NAME>/Swocket.svg?style=flat)](https://travis-ci.org/<NAME>/Swocket)
[![Version](https://img.shields.io/cocoapods/v/Swocket.svg?style=flat)](http://cocoapods.org/pods/Swocket)
[![License](https://img.shields.io/cocoapods/l/Swocket.svg?style=flat)](http://cocoapods.org/pods/Swocket)
[![Platform](https://img.shields.io/cocoapods/p/Swocket.svg?style=flat)](http://cocoapods.org/pods/Swocket)
## Note
This is not ready for production yet. But I'm hoping to have it ready for the world in a couple of weeks.

## TODO
* UDP
* Tests
* Inline C helper methods
* Benchmark
* Cleanup
* Cocoapods

## Usage

To run the example project, clone the repo, and run `pod install` from the Example directory first.

##### Client:
```swift
let data = "Wazzzup".dataUsingEncoding(NSUTF8StringEncoding)!

// Connect to server
client.connect()

// Send message
client.send(data)

// Get response
client.recieve({ (socket, data) -> () in
    // Unwrap response as string and print it
    if let response = String(CString: UnsafePointer<CChar>(data.bytes), encoding: NSUTF8StringEncoding) {
        print(response)
    }
})

// Disconnect
client.disconnect()
```
##### Server:
```swift
let data = "Hello world!\n".dataUsingEncoding(NSUTF8StringEncoding)!

Swocket.listen(1337, onConnection: { (client) -> () in
    client.send(data)
})
```

## Requirements

Xcode 7

## Installation

Swocket <s>is</s> will be available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:

```ruby
pod "Swocket"
```

## Author

<NAME>, <EMAIL>

## License

Swocket is available under the MIT license. See the LICENSE file for more info.<commit_msg>Added example with error closure<commit_after>![Logo](Swocket.png)

[![CI Status](http://img.shields.io/travis/<NAME>/Swocket.svg?style=flat)](https://travis-ci.org/<NAME>/Swocket)
[![Version](https://img.shields.io/cocoapods/v/Swocket.svg?style=flat)](http://cocoapods.org/pods/Swocket)
[![License](https://img.shields.io/cocoapods/l/Swocket.svg?style=flat)](http://cocoapods.org/pods/Swocket)
[![Platform](https://img.shields.io/cocoapods/p/Swocket.svg?style=flat)](http://cocoapods.org/pods/Swocket)
## Note
This is not ready for production yet. But I'm hoping to have it ready for the world in a couple of weeks.

## TODO
* UDP
* Tests
* Inline C helper methods
* Benchmark
* Cleanup
* Cocoapods

## Usage

To run the example project, clone the repo, and run `pod install` from the Example directory first.

##### Client:
```swift
let data = "Wazzzup".dataUsingEncoding(NSUTF8StringEncoding)!

// Connect to server
client.connect()

// Send message
client.send(data)

// Get response
client.recieve({ (socket, data) -> () in
    // Unwrap response as string and print it
    if let response = String(CString: UnsafePointer<CChar>(data.bytes), encoding: NSUTF8StringEncoding) {
        print(response)
    }
})

// Disconnect
client.disconnect()
```
##### Server:
```swift
let data = "Hello world!\n".dataUsingEncoding(NSUTF8StringEncoding)!

Swocket.listen(1337, onConnection: { (client) -> () in
    client.send(data)
})
```

##### Handle errors:
```swift
// All functions have an optional error closure
Swocket.listen(1337, onConnection: { (client) -> () in
    client.send(data)
}) { (error) -> () in
    print(error)
}
```

## Requirements

Xcode 7

## Installation

Swocket <s>is</s> will be available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:

```ruby
pod "Swocket"
```

## Author

<NAME>, <EMAIL>

## License

Swocket is available under the MIT license. See the LICENSE file for more info.
{'fraction_non_alphanumeric': 0.1613599568267674, 'fraction_numerical': 0.005396654074473826, 'mean_word_length': 4.557721139430285, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, 'https://': 8, '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': '7402167', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1251, 'n_words': 313}