I am trying to testing FTP by using SocketChannel, but it is not really in my expectation. I knew that I need to setup a selector algorithm which select the OP_CONNECT, OP_READ key to perform the connect and read function, everything is working fine but why the incoming data is not completely read? On the other hand, if I'm debugging the program, it can be read correctly as I doing it very slow. I thought it is synchronizing issue, so I try to submit only 1 key(even tried hard coded the method step by step, but the issue still existed.
Has anyone met this issue? How can I ensure that the full incoming data is ready to read instead of partial data only, sometimes no data (=.=")