title: Using sockets in Swift like in Java
body: <p>If I wanted to connect to a server, in Java I would open a Socket and initialize it with port and host address, then retrieve the input/output streams and read/write whatever I want.</p>
  
  <p>In Swift I'm having hard time doing so since it's not built that way and I would really like to see a simple example of how to connect to a server, retrieve the streams and use them.</p>
  
  <h2>EDIT1:</h2>
  
  <p>This is the tested code after what @Grimxn referenced.</p>
  
  <pre><code>var host = "http://google.com"
  var readStream :CFReadStreamRef
  var writeStream :CFWriteSteamRef
  var socket = CFStreamCreatePairWithSocketToHost(nil, host, 80, readStream, writeStream)
  </code></pre>
  
  <h2><strong>Main issues:</strong></h2>
  
  <ol>
  <li><p>Initializing the two streams above also require the use of <em>CFAllocator</em> which I know nothing about. Using <em>kCFAllocatorDefault</em> did not quite help, same errors.</p></li>
  <li><p>The above code returns this error: <strong>Cannot Convert the expression's type 'Void' to type UInt32</strong>.</p></li>
  <li><p>When I construct a UInt32 using <strong><em>UInt32(80)</em></strong> for example, the error is: <strong><em>Could not find an overload for 'init' that accepts the supplied argument.</em></strong></p></li>
  </ol>
  
  <p>I appreciate any help!</p>