Mercurial Hosting > luan
comparison src/luan/lib/rpc/RpcCon.java @ 1120:e8fc6712b468
luan Rpc uses luan.lib.rpc
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 07 Aug 2017 23:50:52 -0600 |
parents | 87c674f3f6b7 |
children |
comparison
equal
deleted
inserted
replaced
1119:87c674f3f6b7 | 1120:e8fc6712b468 |
---|---|
16 final Socket socket; | 16 final Socket socket; |
17 final InputStream in; | 17 final InputStream in; |
18 final OutputStream out; | 18 final OutputStream out; |
19 InputStream inBinary = null; | 19 InputStream inBinary = null; |
20 long lenBinary = -1; | 20 long lenBinary = -1; |
21 boolean readSome = false; | |
21 | 22 |
22 RpcCon(Socket socket) | 23 RpcCon(Socket socket) |
23 throws RpcError | 24 throws RpcError |
24 { | 25 { |
25 try { | 26 try { |
88 if( inBinary != null ) { | 89 if( inBinary != null ) { |
89 inBinary.close(); | 90 inBinary.close(); |
90 inBinary = null; | 91 inBinary = null; |
91 lenBinary = -1; | 92 lenBinary = -1; |
92 } | 93 } |
94 readSome = false; | |
93 byte[] a = new byte[4]; | 95 byte[] a = new byte[4]; |
94 readAll(a); | 96 readAll(a); |
95 int len = 0; | 97 int len = 0; |
96 for( byte b : a ) { | 98 for( byte b : a ) { |
97 len <<= 8; | 99 len <<= 8; |
120 int n; | 122 int n; |
121 while( total < a.length ){ | 123 while( total < a.length ){ |
122 n = in.read( a, total, a.length-total ); | 124 n = in.read( a, total, a.length-total ); |
123 if( n == -1 ) | 125 if( n == -1 ) |
124 throw new EOFException(); | 126 throw new EOFException(); |
127 readSome = true; | |
125 total += n; | 128 total += n; |
126 } | 129 } |
127 } | 130 } |
128 | 131 |
129 } | 132 } |