summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Hudson <nick.hudson@isode.com>2012-03-12 17:11:31 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-03-13 10:45:12 (GMT)
commitb2f96e0548abbdaaa097b4908ff4583b4c642772 (patch)
treeeeff86c1370ea179c3a41729074bdabe497e0a7d /.gitignore
parentc5392b36c368ebdca2e8ab356eb0d1fb0d36a5cb (diff)
downloadstroke-b2f96e0548abbdaaa097b4908ff4583b4c642772.zip
stroke-b2f96e0548abbdaaa097b4908ff4583b4c642772.tar.bz2
Update JavaConnection to use SocketChannel rather than Socket
The initial implementation of JavaConnection used the "Socket" class, from which it derived InputStream and OutputStream objects to read/write data. In order to avoid blocking, the "read" loop would only attempt to read data if the InputStream.available() method indicated that there was data ready to be read. However, in order to determine that an InputStream has been closed, you have to read from it and have it return -1 to indicate "end-of-stream". There was no explicit test for a -1 return, but even if there had been, it wouldn't have tripped, because of the "available()" test. So this change makes JavaConnection use "SocketChannel" rather than Socket, which allows (when you configure the SocketChannel to be non-blocking) you to issue non-blocking reads which *can* return -1 when the input stream has finished. Test-information: Tested with test program and MLC, using both TLS and non-TLS connections. Applications still work as expected. Observed that when I deliberately stop the server, or break the socket connection, the client almost immediately gets a "disconnected" signal. Prior to this change, stopping the server results in the client getting a disconnected signal only when it next tries to write something.
Diffstat (limited to '.gitignore')
0 files changed, 0 insertions, 0 deletions