Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add C7.Stream support #36

Closed
tanner0101 opened this issue Jun 5, 2016 · 2 comments
Closed

add C7.Stream support #36

tanner0101 opened this issue Jun 5, 2016 · 2 comments

Comments

@tanner0101
Copy link
Collaborator

Adding C7 Stream support would allow people to easily import Socks and plug it into their existing Stream code.

If this is something @czechboy0 thinks should be included in Socks, it should be pretty easy.

extension Socks.TCPClient: Stream {
    public enum Error: ErrorProtocol {
        case unsupported
    }

    public var closed: Bool {
        return socket.isClosed
    }

    public func send(_ data: Data, timingOut deadline: Double) throws {
        try send(bytes: data.bytes)
    }

    public func flush(timingOut deadline: Double) throws {
        throw Error.unsupported
    }

    public func receive(upTo byteCount: Int, timingOut deadline: Double) throws -> Data {
        let bytes = try receive(maxBytes: byteCount)
        return Data(bytes)
    }
}

This would also rely on #35 since C7 stream includes a closed property.

@czechboy0
Copy link
Collaborator

Actually, I'd prefer to hold off on adding C7 as a dependency here until we have a bit more we get out of it (especially nowadays when I frequently get a conflict of C7 versions high up the dependency tree, so until things stabilize a bit I'd prefer to hold off).

I hope it's not too much trouble for Vapor to include this extension in your repo for now and I expect to add this later down the line when there aren't new versions of C7 being released so often.

@tanner0101
Copy link
Collaborator Author

As long as #35 is solved in a way that doesn't create conflicts with C7.Stream (basically using var closed: Bool) then it's totally fine to hold off on C7 support inside of Socks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants