title: How to read from socket without blocking
body: <p>I ran into a problem when dealing with the server, sending me initial "greetings header" (smtp server):</p>
  
  <p>I need to read this header before send any commands and receive any answers from the server, but i dont know, how to do this, because Julia seems to lack any possibility to readi from IO stream without blocking: "read" command and its analogues does not have any NB-options, nb_available always is 0 though i know exactly that server send me header and my read buffer cant be empty (and "read" command issued right after "nb_available" give me data immediately, without blocking).</p>
  
  <pre><code>julia&gt; s=connect("smtp.mail.ru",25)
  TCPSocket(RawFD(18) open, 0 bytes waiting)
  
  julia&gt; nb_available(s)
  0
  
  julia&gt; nb_available(s)
  0
  (after 5 seconds or so...)
  julia&gt; nb_available(s)
  0
  
  julia&gt; t=read(s,10)
  10-element Array{UInt8,1}:
   0x32
   0x32
   0x30
   0x20
   0x73
   0x6d
   0x74
   0x70
   0x31
   0x34
  (HOW, WHY???? nb_available==0, but read returns me 10 bytes?!)
  
  ... (read was repeated many times...)
  julia&gt; t=read(s,10)
  ^CERROR: InterruptException:
  Stacktrace:
   [1] process_events at ./libuv.jl:82 [inlined]
   [2] wait() at ./event.jl:216
   [3] wait(::Condition) at ./event.jl:27
   [4] wait_readnb(::TCPSocket, ::Int64) at ./stream.jl:296
   [5] readbytes!(::TCPSocket, ::Array{UInt8,1}, ::Int64) at ./stream.jl:714
   [6] read(::TCPSocket, ::Int64) at ./io.jl:529
  </code></pre>
  
  <p>I dont want to use @async for the simplest case described above. </p>
  
  <p>Who knows, how to read from TCP socket in non-blocking mode, when i can determine some way, whether read buffer contain any data or no and/or whether next read issued by tcp client will block overall client process or no.</p>
  
  <p>Is it possible in Julia without "green threads" usage?</p>