title: What would be the Spring way of using TCP connections?
body: <p>I am reading and write XML over a TCP connection (not HTTP) as part of a web service I'm developing, and I was wondering whether there is a more "springified" way (or even other ideas) of achieving what I'm trying below:</p>
  
  <pre><code>    InputStream is = null;
      OutputStream os = null;
      Socket s = null;
      try {
          s = new Socket(address, portNo);
          os = s.getOutputStream();
          os.write(msg.getBytes());
          os.flush();
          is = s.getInputStream();
          String xml = IOUtils.toString(is);
          return xml;
      } finally {
          IOUtils.closeQuietly(os);
          IOUtils.closeQuietly(is);
          if (s != null) s.close();
      }
  </code></pre>
  
  <p>Note, I've got no control over the server, so I don't think I'll be able to use Spring remoting, but was wondering whether this can be improved akin to spring's JdbcTemplates.</p>
  
  <p>EDIT:</p>
  
  <p>Note, just to clarify IOUtils is Apache commons-io...</p>