I am sending jpg images via TCP, using InputStream and OutputStream:
I can send a picture, but when I try to receive a picture, I get a "Bad Socket" error.
Based on the following:
http://www.mail-archive.com/android-dev ... 02516.html
I figured that my problem was that invoking the outputStream.close() after the first image was sent was somehow interfering with my preestablished inputStream. (If I didn't use outputStream.close() then the first image transmission never concludes properly.) I don't really understand why this is so [Any ideas?], but anyway I tried to use the outputStream.flush() (per the above html) but when I did this (without using outputStream.close()), the picture is never transmitted.
In looking at the Android API for OutputStream (http://code.google.com/android/referenc ... tream.html), I found several interesting issues.
1) "OutputStream is an abstract class..." : Well if that is so, how is that I was able to instantiate concrete variables of type OutputStream? OK, maybe they just never updated the API documentation from earlier??? Don't know...
2) regarding the android documentation of the flush() method:
"public void flush()
Flush this OutputStream. Concrete implementations of this class should ensure any pending writes to the underlying stream are written out when this method is envoked. This implementation does nothing. "
Is this why the .flush() method is not working? Although, the .close() method does seem to work to finalize sending the image, and the documentation for the .close() method in the API also says: "This implementation does nothing. ".
So, The question is : Can anybody guide me in where to find out how to write the code that the Android API recommends to "ensure any pending writes to the underlying stream are written out when this method [.flush()] is envoked"? Or give any other insight?