This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Sending files and text over a I/O Stream  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Bartender
Posts: 3320
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!