title: How to bind sockets in Ruby?
body: <p>I'm tring to use ruby Socket class directly, TCPSocket is not an option.
  Code:</p>
  <pre><code>require 'socket'
  include Socket::Constants
  
  socket = Socket.new :INET, :STREAM, 0
  socket.bind (Socket.pack_sockaddr_in 2200, 'localhost')
  </code></pre>
  <p>Error:</p>
  <blockquote>
  <p>`bind': An address incompatible with the requested protocol was used.
  (Errno::EAFNOSUPPORT)</p>
  </blockquote>
  <p>I'm using ruby 1.9.3 in a Windows machine.</p>
  <p>Extra info:</p>
  <blockquote>
  <p>Socket.pack_sockaddr_in(2200, 'localhost')</p>
  <p>=&gt; &quot;\x17\x00\b\x98\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00&quot;</p>
  </blockquote>
  <p>Hosts file:</p>
  <blockquote>
  <p># localhost name resolution is handled within DNS itself.<br>
  #    127.0.0.1       localhost<br>
  #    ::1             localhost</p>
  </blockquote>