title: How do you send a User defined class object over a tcp/ip network connection in java?
body: <p>This is an example of a user defined class I'd like to send from a client application to a server application:</p>
  
  <pre><code>class dataStruct implements Serializable{
      byte data;
      int messageNum;
      public void setData(byte datum, int messageNumber){
          data=datum;
          messageNum=messageNumber;
      }
  }
  </code></pre>
  
  <p>How do you send a user defined class over a tcp/ip connection in java?</p>
  
  <p>What types of streams can I use to accomplish this (if I'm sending more than just text)?</p>
  
  <p>Can I pass a full object via a socket stream, or will I always have to cast it after it has been passed via a stream?</p>
  
  <p>I'm writing a server/client application, and I've only been able to find tutorials with examples of primitive types or strings being passed over a network connection - not user defined types.</p>
  
  <p>Your help and direction are greatly appreciated.</p>