title: Serial Port Connection Between Host and Guest with Virtualbox
body: <p>I'm trying to learn how to write C code that will read from the serial port in Linux. I've found what seems to be a good tutorial <a href="http://www.tldp.org/HOWTO/Serial-Programming-HOWTO/x115.html" rel="noreferrer">here</a>. </p>
  
  <p>I want to be able to test this code, so I think I need either a serial port, or a way to write to the serial port while the code from above is reading.</p>
  
  <p>I'm running Ubuntu 10.04 as a virtual machine on my Mac using virtualbox. My idea was to set up a virtual serial connection and write from the host to the guest. Hopefully something as simple as <code>cat "Hello World" &gt; /tmp/fake_serial</code> in a host terminal, and for that to be read by the program in the link above. </p>
  
  <p>Is this possible? I've tried adding a serial port using virtual box and when I try to do the above command I get an error saying I can't write to a socket.</p>
  
  <p>The second option I thought of was using something like <code>minicom</code> inside the guest OS, to connect to say <code>/dev/ttyS1</code> and write messages for my code to read at the same time. Again, assuming that the baud rates and other settings are OK, would this be possible? </p>
  
  <p>I don't have a lot of experience working with serial ports, so I'd appreciate any suggestions about the best way to do this. Thanks in advance.  </p>