> On Sep 20, 2025, at 4:02 AM, Owen Thomas <[email protected]> wrote: > > On Sat, 20 Sept 2025 at 16:37, Owen Thomas <[email protected]> > wrote: > >> So, my question is this: How do I transmit and receive data over sockets >> with Fory? How does 'Fory facilitate the communication of binary data over >> the sockets in general, and how does one use the Java Fory API to do this. >> > > Maybe this is making things too complex, but thinking about this a little > more, I am wondering if, for Java, there might be, say, an input stream > reader: call it ForyInputStreamReader that could wrap a socket's > InputStream. This could do all the decoding of the Fory metadata and > ensure the input stream conformed to what Fory is expecting. > > So, the syntax might be: > > Fory fory=...; > Socket socket=...; > SomeClass cls=new > ForyInputStreamReader(fory,socket.getInputStream(),SomeClass.class).read();
Hi Owen, Fory translates your objects into bytes, but does not (as far as I know) provide special input or output stream semantics. Just taking the byte[]s produced by Fory serialization, possibly adding some sort of framing (simplest implementation is to just write the length then the bytes), sending it over the stream, and reading back the same byte[]s to Fory deserialize should be sufficient. I did not make the decision, but I would guess this is left up to your implementation right now, because there are many different protocols and framing approaches you might want to use. Raw sockets are relatively out of style nowadays in the world of HTTP and GRPC etc. If you've got ideas for how adding a specialized fory input / output stream would help, I think you could open a feature request, and please be specific about which features you feel are missing or are best provided by the library rather than the end-user. Do note that the object-serialization protocol provided by the "Fory" class writes the metadata inline, so as far as I know the deserialization process does not require SomeClass.class as a parameter. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
