client-server file exchange
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
The following are the codes for client and server to exchange a file. It works like this: The client sends a connection request and the server begins to transfer the file and the client just recieves the file. The location of the file and the size of the file are predefined, for the sake of simplicity.
How is it that the client reads from the InputStream only after the Server sends the data and not before it sends data? How does it know when to start reading from InputStream? I am presently running the client and server on local host and the code is working fine.
client code:
Server code:
How is it that the client reads from the InputStream only after the Server sends the data and not before it sends data? How does it know when to start reading from InputStream? I am presently running the client and server on local host and the code is working fine.
client code:
Server code:
posted 14 years ago
What would it read if the server hasn't sent anything yet? The read method simply blocks until some data is available. Be aware that this may not everything that was sent; some bytes may still be on their way. That's why you usually should read in while loops.
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Haritha Gorijavolu wrote:How is it that the client reads from the InputStream only after the Server sends the data and not before it sends data? How does it know when to start reading from InputStream?
What would it read if the server hasn't sent anything yet? The read method simply blocks until some data is available. Be aware that this may not everything that was sent; some bytes may still be on their way. That's why you usually should read in while loops.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Got it. Thanks for explaining. 

posted 14 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
You're welcome.
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
| I child proofed my house but they still get in. Distract them with this tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |












