This is an example of a user defined class I'd like to send from a client application to a server application:

class dataStruct implements Serializable{
    byte data;
    int messageNum;
    public void setData(byte datum, int messageNumber){
        data=datum;
        messageNum=messageNumber;
    }
}

How do you send a user defined class over a tcp/ip connection in java?

What types of streams can I use to accomplish this (if I'm sending more than just text)?

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?

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.

Your help and direction are greatly appreciated.

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top