How to read efficiently from socket using Java NIO

后端 未结 2 508
旧时难觅i
旧时难觅i 2021-02-11 05:37

I am working on task involving reading from the socket trading quotes and I need to achieve minimum latency and high throughput.

I started with the simpliest possible ja

2条回答
  •  孤街浪徒
    2021-02-11 06:10

    Assuming you can adapt your parser API to accept (byte[] buffer, int offset, int length) as arguments, you can just pass (bb.array(), 0, bb.limit()) as parameters and not have to create the new byte[] at all per read. However this isn't likely to be the rate-determining step.

提交回复
热议问题