Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

read/write data byte-per-byte to and from a socket

Thread view: 
crash.test.dummy - 17 Feb 2006 06:01 GMT
the usual data handling that i know in sockets is by using an input
stream and output stream for reading and writing data, respectively:

PrintWriter out = new PrintWriter(clientSocket.getOutputStream(),
true);
BufferedReader in = new BufferedReader(new
InputStreamReader(clientSocket.getInputStream()));

1. how do i read data byte-per-byte from a socket?
2. how do i write data byte-per-byte to a socket?

thanks.
Knute Johnson - 17 Feb 2006 06:18 GMT
> the usual data handling that i know in sockets is by using an input
> stream and output stream for reading and writing data, respectively:
[quoted text clipped - 8 lines]
>
> thanks.

Just use the InputStream and OutputStream that you get from the socket.

Actually it is interesting that you asked this question this way.  There
are a lot of posts here periodically where people are having trouble
getting their data moved around.  It is almost always caused by using
some extension of FilterOutputStream/InputStream and available.  Use
InputStream/OutputStream for binary data and buffer it yourself or add a
BufferedInputStream/OutputStream.  For text or string data use
BufferedReader/Writer.  Those will cover 99% of all the I/O you need to do.

Signature

Knute Johnson
email s/nospam/knute/



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.