title: Why is pySerial socket protocol not supporting fileno()?
body: <p>My goal is to be able to use the python expect module on a uart serial interface. </p>
  
  <p>I'm trying to hook-up the pySerial (<code>serial</code>) python module to the <code>pexpect</code> module. However, I'm accessing the serial port remotely via a socket with the <code>serial.serial_for_url()</code> function using the socket protocol. </p>
  
  <p>When doing so, it fails because <code>select()</code> needs to have <code>fileno()</code> define in the Serial object. I get the following error:
  <code>io.UnsupportedOperation: fileno</code></p>
  
  <p>Why can the socket protocol use the <code>socket.fileno()</code>?
  I tried it and it seems to work properly under linux. </p>
  
  <p>Is there any reason why this shouldn't be supported by default in <code>serial.urlhandlers.protocol_socket.py</code>?</p>
  
  <p><strong><em>Edit</em></strong>:</p>
  
  <p>I ran the following:</p>
  
  <pre><code>&gt;&gt;&gt; import serial
  &gt;&gt;&gt; import fdpexpect
  &gt;&gt;&gt; fd = serial.serial_for_url('socket://10.28.1.15:7002')
  &gt;&gt;&gt; px = fdpexpect.fdspawn(fd, logfile=open('test.log','w'))
  </code></pre>
  
  <p>Note that you need hardware that have a uart-to-network bridge. I use a Digi32CM in that particular test, but it's not really relevant.</p>
  
  <p>When I run the <code>fdspawn()</code> function, I get the following error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "python2.7/site-packages/pexpect/fdpexpect.py", line 45, in __init__
      fd = fd.fileno()
  io.UnsupportedOperation: fileno
  </code></pre>
  
  <p>pySerial <code>Serial</code> object does not define the <code>fileno()</code> function even though it is based on a socket and could use the socket fileno. When I tried adding it, the operation seems to work fine:</p>
  
  <pre><code>def fileno(self):
      return self._socket.fileno()
  </code></pre>
  
  <p>I'm wondering if I'm missing something?</p>