Swift streams and sockets -- help needed

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Swift streams and sockets -- help needed

Jerzy Głowacki
Hello,

Could anybody please help solving this problem: Swift streams and sockets?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/2e51890f-91c0-4527-b5ec-266a3ea4d15e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Swift streams and sockets -- help needed

Tom Lieber
You can pop this into a Playground to learn about NSInputStream:

import Cocoa

// create some data to read
let data: NSData = "Howdy,
pardner.".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion:
true)
data.length

// create a stream that reads the data above
let stream: NSInputStream = NSInputStream(data: data)

// begin reading
stream.open()
var buffer = [UInt8](count: 8, repeatedValue: 0)
while stream.hasBytesAvailable {
    let result: Int = stream.read(&buffer, maxLength: buffer.count)
    result // the number of bytes read is here
    buffer // the data read is in here
}


On Sat, Jul 26, 2014 at 8:32 AM, Jerzy Głowacki <[hidden email]> wrote:
Hello,

Could anybody please help solving this problem: Swift streams and sockets?

Thanks!

--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/2e51890f-91c0-4527-b5ec-266a3ea4d15e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Tom Lieber
http://AllTom.com/
http://infinite-sketchpad.com/

--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/CAProext4jQczVbagjK5XoY2JfTgHMV3jTjhJG-pC1_q6U7dXFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Swift streams and sockets -- help needed

Jerzy Głowacki
Thanks a lot! Your answer has been posted under the original question.

--
You received this message because you are subscribed to the Google Groups "Swift Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/swift-language/9a8ba808-b5e9-4735-be2b-fc0b76a802f7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.