0

I'm writing a Swift application under OS X that needs to do TCP/IP port-level network I/O (optionally with SSL/TLS). I've done a lot of searching and it looks like NSStream is the way to go for this. However, the class reference for NSStream says that the class method getStreamsToHost() is deprecated as of OS X 10.10, which appears to be what I need to use, but doesn't say what replaces it. Does anyone know what mechanism I need to use in order to connect to a host on a specific port (no, not 80) in order to do the I/O in Swift under OS X?

1 Answer 1

2

It has been replaced with getStreamsToHostWithName.

Example:

var input: AutoreleasingUnsafeMutablePointer<NSInputStream?> = nil
var output: AutoreleasingUnsafeMutablePointer<NSOutputStream?> = nil

NSStream.getStreamsToHostWithName(YOUR_HOST, port: YOUR_PORT, inputStream: input, outputStream: output)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.