 <p><em>(From the above comments:)</em> There are several problems here:</p> <ul> <li><p>You pass the address of the local variable <code>var selfPtr</code> to the callback. That address becomes invalid as soon as the <code>hookUpSocket()</code> function returns. See <a href="http://stackoverflow.com/questions/30786883/swift-2-unsafemutablepointervoid-to-object">Swift 2 - UnsafeMutablePointer&lt;Void&gt; to object</a> for a way to pass a pointer to <code>self</code> to the callback, more information here: <a href="http://stackoverflow.com/questions/33294620/how-to-cast-self-to-unsafemutablepointervoid-type-in-swift">How to cast self to UnsafeMutablePointer&lt;Void&gt; type in swift</a>.</p></li> <li><p><code>inputStream</code> and <code>outputStream</code> must be registered with a run loop.</p></li> <li><p><code>inputStream</code> and <code>outputStream</code> are local variables of the callback function so they are deallocated when the function returns. They should be properties of your class instead.</p></li> </ul>