MCPcopy Create free account
hub / github.com/Q16G/memory-shell / peekRead

Method peekRead

src/main/java/org/example/Socks5Server.java:192–213  ·  view source on GitHub ↗
(ByteBuffer rawBuffer, int expectedBytes)

Source from the content-addressed store, hash-verified

190 }
191
192 private boolean peekRead(ByteBuffer rawBuffer, int expectedBytes) throws IOException {
193 if (readBuffer == null) {
194 throw new IOException("读取缓冲区未初始化");
195 }
196
197 // 检查是否有足够的数据
198 if (readBuffer.remaining() < expectedBytes) {
199 return false;
200 }
201 // 保存当前position
202 int originalPosition = readBuffer.position();
203
204 // 读取数据
205 byte[] data = new byte[expectedBytes];
206 readBuffer.get(data);
207
208 this.peekPosition += expectedBytes;
209 // 恢复position
210 readBuffer.position(originalPosition);
211 rawBuffer.put(data);
212 return true;
213 }
214
215 private void handleDataTransfer(SocketChannel channel) {
216 // 数据转发已经在handleConnectionRequest中启动

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected