I'm trying to make a client/socket program that involves sending a string from the client (to identify which key should be used), the server sends back a key in byte form, the client then sends a request for a file in string form, the server sends the requested file to the user which can be decrypted with they key.
I understand the cryptology aspects, I'm hung up on how to differentiate between sending bytes, string or a file to and from a server. I understand how to send a single stream (bytes, string or a file), but cannot find a way to send all of these in one stream if that makes any sense?
Do I have to create a new stream each time I want to send a string, then a new one to send bytes, then a new one to send a file?
Any resources I could perhaps look up? Cheers!
Post by:Tony Docherty
An OutputStream sends everything as bytes. You can wrap them in higher level classes that allow you to write other data types such as Strings but they still are sent as bytes. The same applies to the InputStream so as long as your client and server know what data types to expect and in what order you can write (send) and read (receive) any data type over a single stream.
If a complex set of data of varying data types is to be sent it may be easier to place that data in an object and send the object (Memento).
Screaming fools! It's nothing more than a tiny ad: