How to convert received data to inputstream and outputstream
<p>I have to create TCP/IP server for RPC communications. I'm bound to using a provided java lib that handles all the "rpc" stuff. This lib received HDLC messages that contain protobuf data. The lib itself uses request and response handlers to handle the HDLC and protobuf part. This lib can be used for serial connections as well as networked connections.</p>

<p>We'd like to use netty for the TCP server for this. When calling this lib it expects an <code>java.io.inputstream</code> and <code>java.io.outputstream</code> in the "RPC" method.</p>

<p>I have a simple blocking setup, in which I create a server socket, and just pass a <code>socket.getInputStream()</code> and <code>socket.getOutputStream()</code> to the RPC method. Next I need to register a (set) of rpc handlers to this rpc object, and than clients can connect and data can be send. Seems pretty straightforward to me.</p>

<p>I've also setup a netty "echo" server and now I want to use this RPC library with netty. What I'm struggling with is how to convert my received data to the required <code>InputStream</code> and how to convert the <code>OutputStream</code> of the RPC lib so that it can be send back to the client. Do I need a decoder/encoder, or is there a simpler way to do this? And if so, how do I transform the <code>ByteBuf</code> to an <code>InputStream</code> and the <code>OutputStream</code> back the format that can be send over the network?</p>