I'm new to Javolution and C/C++ . But I really like it so far and I think makes the code much cleaner.
I have been playing with the UDP example that can be found here http://javolution.org/target/site/apidocs/javolution/io/Struct.html
It is working well except when I use UTF8String. Is this normal.
So for I have a Struct like this
public class UserTest extends Struct
{
public Unsigned8 age = new Unsigned8();
public UTF8String name = new UTF8String(8);
}
then i have another class that sends via udp the struct
ByteBuffer buf = ByteBuffer.allocate(1400);
DatagramChannel channel = DatagramChannel.open();
channel.connect(new InetSocketAddress("localhost", 54300));
buf.clear();
buf.put(userStruct.getByteBuffer());
buf.flip();
channel.write(buf);
Now on the otherside of the connection I have the following
channel.receive(buffer);
buffer.flip();
userStruct.getByteBuffer().put(buffer);
System.out.println("Do I have a name >>>> "+ userStruct.name.get());
System.out.println("Do I have an age >>>> "+ userStruct.age.get());
Now this doesn't work but I remove name and just keep age then I can retrieve the value of age?
Is it possible to send String via Struct over the network?
Thank you, Anthony